Magento2: wysiqyg-media subdirectories are created wrong when database as media storage is used

Created on 28 Jul 2016  路  10Comments  路  Source: magento/magento2

when using the database as media storage, magento checks wether or not the directories found in the database exist. unfortunately this checks goes wrong and it ends up creating folders just like the absolute path inside the wysiwyg folder.

Preconditions

  1. magento 2.0.7

    Steps to reproduce

  2. enable database media storage

  3. bring up a cms page
  4. click insert image

    Expected result

  5. no uncessary folders are being created

    Actual result

  6. unnecessary folders are being created (and never used)

Example:
if magento resides in /var/www/html and thus you have the folder /var/www/html/pub/media/wysiwyg magento will create the folder /var/www/html/pub/media/wysiwyg/var/www/html/pub/media/wysiwyg

Afaik the Problem lies in vendor/magento/module-cms/Model/Wysiwyg/Images/Storage.php in the method createSubDirectories($path) on line 199-201 a directory is supposed to create a path, but is given an absolute path, but the directory creates this relative to its own location, thus the wring result in the path

Cms bug report

All 10 comments

Does it cause any other problem than creating one redundant empty folder?

i just deleted my whole wysiwyg folder and now magento is unable to synch the files back from the database because the folders are missing, so its not just obsolete wrong folders but actually the ones magento needs are missing (what else would be the point of creating them in the first place)

tl;dr yes it breaks the media synch for cms/wysiwyg

my fix is this:
replace:
$fullPath = rtrim($path, '/') . '/' . $directory['name']; $this->_directory->create($fullPath);
with:
$this->_directory->create($directory['path'].'/'.$directory['name']);

@ludwig-gramberg is it this issue? #5705

nope, this is something different

this appears to be fixed in 2.1.2 can someone form the magento team confirm this?

@ludwig-gramberg Unfortunately I could not reproduce this issue.
I need more information about this issue in order to successfully investigate potential fixes. Please use our issue tracking template to format your description. Specify the exact steps you used.

@IlnitskiyArtem well I did, the faulty behaviour is that a folder that is intended as an absolut path is created in relation to the existing media folder, thus creating faulty paths like this one:
/var/www/html/pub/media/wysiwyg/var/www/html/pub/media/wysiwyg
it repeats the absolute path within the media directory

@IlnitskiyArtem also as I wrote I did not observe this behaviour any more since version 2.1.2

I'm closing this issue as it is not reproduces any more.
If you can still reproduce this issue, please create a new GitHub issue report.

Was this page helpful?
0 / 5 - 0 ratings