-
Notifications
You must be signed in to change notification settings - Fork 9.4k
MC-41852: issue with product image cache #32768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MC-41852: issue with product image cache #32768
Conversation
Hi @temptask. Thank you for your contribution
❗ Automated tests can be triggered manually with an appropriate comment:
You can find more information about the builds here ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review. For more details, please, review the Magento Contributor Guide documentation. 🕙 You can find the schedule on the Magento Community Calendar page. 📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket. 🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel ✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel |
Can you cover your changes with automation tests |
- Reverted regular expression value to previous state (before performance improvements) to work correctly with all image names
@magento run all tests |
@magento run Functional Tests CE, Functional Tests B2B |
Hi @Den4ik, thank you for the review. |
Hi @sidolov @sivaschenko, Also, breaks the cases when the path is customized by extensions. There no easy way to fix it, as method is private, so the only way to fix that now - apply patch. PS: I believe we should cover this replace with some unit tests and add multiple data samples, not just a single MFTF test |
Hi @ihor-sviziev, thank you for the review. |
✔️ QA Passed Preconditions:
Manual testing scenario:
Before: ✖️ Image were not getting displayed in the product details page. After: ✔️ Images are getting displayed in the product details page. Tried to delete the uploaded files , and tried to replace with new image files as such. No issues noticed. There is no additional testing is required as part of regression since there is MTFT already covered with this PR. |
Description (*)
This PR fixes issue when product image that contains dot in image name at first or second position (e.g. "i.mage.png") is not showing on frontend after flushing catalog image cache.
This happened because when uploading product image magento uses files dispersion setting and saving image to path generated by
\Magento\Framework\File\Uploader::getDispersionPath
which consists of two directories defined by two first letters of filename (e.g. path for "image.png" will be /i/m/image.png). But, in case when there is dot in first two letters of filename, directory name with underscore will be used (e.g. path for filename "i.mage.png" will be /i/_/image.png).When catalog image cache is flushed and frontend product image is requested magento tries to create new cache file in
\Magento\MediaStorage\App\Media::createLocalCopy
and tries to retrieve original image location by calling\Magento\MediaStorage\App\Media::getOriginalImage
.This function is using regexp to get from path like "media/catalog/product/cache/838ef3af6b51df9f635b7eb110d280c6/i/m/image.png" original image path "/i/m/image.png".
This regexp was changed in 362eba8 from
|^.*((?:/[^/]+){3})$|
to|^.*?((?:/([^/])/([^/])/\2\3)?/?[^/]+$)|
. New regexp (|^.*?((?:/([^/])/([^/])/\2\3)?/?[^/]+$)|
) is not taking into consideration cases when original filename contained dot in first two letters and therefore path with underscore instead of dot is generated.In this PR old regexp (
|^.*((?:/[^/]+){3})$|
) was restored since its working correctly with all filenames.Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Actual result: (before this PR)
Placeholder showed instead of product image
Expected result: (after this PR)
Product image is showed
Questions or comments
Since commit 362eba8 that changed working regexp to not correctly working with all filenames regexp was introduced with "[performance]" text in commit message, it was probably fixing some performance issues of older regexp.
In this PR it was decided not to modify this not fully working regexp but rather restore old one because it was not very clear what performance changes is was making and because of possible risks of introducing new regexp.
So, reviewer probably should take a close look at deleted regexp before accepting this PR.
Contribution checklist (*)