Description
Preconditions (*)
- Magento 2.4.6-p4
- Magento 2.4.7
- Magento Developer branch
- Indexer mode: Update by schedule
Description (*)
When we upload an image to the product and without saving the product again we delete the image and then we save the product, the image is added for resize in queue. And the error of system message is shown with failure of queue message.
Steps to reproduce (*)
- Access magento admin panel and set the indexer mode to Update by Schedule
- Go to Catalog->Product.
- Create a product or edit any existing product and upload a image and again remove the uploaded image without saving the product.
- Then save the product.
- Run media.storage.catalog.image.resize consumer
Expected result (*)
As the image was not saved to the product, hence the image should not be added to the queue for image resize.
Actual result (*)
As the image was not saved to the product, but the image is getting added to the queue for image resize.
Additional information (*)
When we upload the image, a copy of the image is created in tmp folder. And when we remove the image without saving the product the image in the tmp folder is not removed and hence the path of the image is sent to the Image resize queue due to which the consumer is not able to locate the .tmp image file in pub/media/catalog/product path as the .tmp image never existed in the given path.
Hence, it results into the failure of queue and it throws a system message.
Files:
- magento/module-catalog/Controller/Adminhtml/Product/Gallery/Upload.php
- magento/module-catalog/Observer/ImageResizeAfterProductSave.php
- magento/module-media-storage/Service/ImageResize.php
Upload controller is called when we upload a image and it sets the response and send it to the ImageResizeAfterProductSave observer in which the image file name is sent to the queue using ImageResize.
Even if we remove the product image right after uploading it and without saving the product, Upload controller still send the image path with .tmp extension to the observer and from there it goes to queue which fails afterwards.
Activity