magento2: Category image does not copy from catalog/tmp/category to catalog/category directory when saving category whilst using database storage method

Preconditions

  1. Magento 2.4-develop

Steps to reproduce

  1. Set media storage to database
  2. Upload category image in admin section
  3. Save the category

Expected result

  1. The image row in media_storage_file_storage table should have directory catalog/category and correct directory_id

Actual result

  1. The image row in media_storage_file_storage table has directory catalog/tmp/category

I believe the problem lies with the directory_id not being changed in method Magento\MediaStorage\Model\ResourceModel\File\Storage\Database::copyFile

https://github.com/magento/magento2/blob/2.2-develop/app/code/Magento/MediaStorage/Model/ResourceModel/File/Storage/Database.php#L275

When I manually change the directory_id in $data from the catalog/tmp/category directory_id to the catalog/category directory_id before running the $connection->insertOnDuplicate method the file is correctly copied to another row with the correct data.

As another note, should it not convert the existing row to simply change the directory_id and directory rather than copying to a new row…

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Reactions: 3
  • Comments: 22 (10 by maintainers)

Most upvoted comments

@davidwindell, sorry that was just mistake.