Skip to content

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

Closed
@minlare

Description

@minlare

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...

Metadata

Metadata

Assignees

Labels

CDIssue recommended for the contribution dayComponent: CatalogComponent: MediaStorageIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReproduced on 2.1.xThe issue has been reproduced on latest 2.1 releaseReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 releaseReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions