magento2-40388: Generates only the requested resized image when a missing cache URL is opened
Community fix magento2-40388 merged into magento/magento2 on 2026-07-06, not in a release yet; applies cleanly to 2.4.9.
Generates only the requested resized image when a missing cache URL is opened edited
- Pull request title
- Improve performance when resized image URL is accessed but does not yet exist.
- Pull request
- magento/magento2#40388
- Issues
- #40399 pr-derived
- Author
- @rogerdz
- Merged
- 2026-07-06
- Fixed in
- no release yet
- Reported on
- —
- Categories
- Content
- Components
- magento/module-media-storage
Labels
- Area
- Content / CMS
- Component
- Image
- Priority
- P2
- Severity
- —
- Reported on (labels)
- 2.4.x
Issue
Title and steps come from the upstream issue and pull request.
Description
This increases response time and disk I/O.
Test with PR when accessing one missing resized image URL, response time decreased from 1s to 150ms
Steps to reproduce
2. Go to any resize image (example: https://magento2.test/media/catalog/product/cache/2765542505660baab28ecd555e27366e/w/t/wt09-white_main_2.jpg)
3. Find all resize image (example: find pub/media/catalog/product/cache/ -type f -name '*wt09-white_main_2.jpg')
4. Should create only resize image with hash 2765542505660baab28ecd555e27366e
Taken from the upstream pull request.
Code match per tag
Each tag was checked with git apply --check against that tag's files. A clean match means the change applies; it is not a test result. Tags that already contain the fix are marked.
| Line | Code match per tag | Tests |
|---|---|---|
| 2.4.6 | 2.4.6 conflict 2.4.6-p1 conflict 2.4.6-p2 conflict 2.4.6-p3 conflict 2.4.6-p4 conflict 2.4.6-p5 conflict 2.4.6-p6 conflict 2.4.6-p7 conflict 2.4.6-p8 conflict 2.4.6-p9 conflict 2.4.6-p10 conflict 2.4.6-p11 conflict 2.4.6-p12 conflict 2.4.6-p13 conflict 2.4.6-p14 conflict 2.4.6-p15 conflict | 2.4.6: no test data 2.4.6-p1: no test data 2.4.6-p2: no test data 2.4.6-p3: no test data 2.4.6-p4: no test data 2.4.6-p5: no test data 2.4.6-p6: no test data 2.4.6-p7: no test data 2.4.6-p8: no test data 2.4.6-p9: no test data 2.4.6-p10: no test data 2.4.6-p11: no test data 2.4.6-p12: no test data 2.4.6-p13: no test data 2.4.6-p14: no test data 2.4.6-p15: no test data |
| 2.4.7 | 2.4.7 conflict 2.4.7-p1 conflict 2.4.7-p2 conflict 2.4.7-p3 conflict 2.4.7-p4 conflict 2.4.7-p5 conflict 2.4.7-p6 conflict 2.4.7-p7 conflict 2.4.7-p8 conflict 2.4.7-p9 conflict 2.4.7-p10 conflict | 2.4.7: no test data 2.4.7-p1: no test data 2.4.7-p2: no test data 2.4.7-p3: no test data 2.4.7-p4: no test data 2.4.7-p5: no test data 2.4.7-p6: no test data 2.4.7-p7: no test data 2.4.7-p8: no test data 2.4.7-p9: no test data 2.4.7-p10: no test data |
| 2.4.8 | 2.4.8 conflict 2.4.8-p1 conflict 2.4.8-p2 conflict 2.4.8-p3 conflict 2.4.8-p4 conflict 2.4.8-p5 conflict | 2.4.8: no test data 2.4.8-p1: no test data 2.4.8-p2: no test data 2.4.8-p3: no test data 2.4.8-p4: no test data 2.4.8-p5: no test data |
| 2.4.9 | 2.4.9 clean | 2.4.9: fails before, passes afterunit: fails before, passes after |
Triage
Model @cf/cloudflare/clef. Probability this is a bug fix: 10.5%. Probability it is security relevant: 0.8%.
Show the model's answers and probabilities
| Question | Answer | Probabilities | Confidence |
|---|---|---|---|
| Change kind | refactor | refactor 48.0%, bugfix 36.8%, feature 10.6%, tests_only 3.0%, dependency 0.9%, docs_only 0.8% | 25.4% |
| Area | framework | framework 28.2%, other 27.0%, catalog 25.1% | 13.1% |
| Reported version | unspecified | unspecified 20.4%, 2.4.6 3.7%, 2.4.6-p1 2.5% | 4.0% |
| Scope | 1.08 of 2 | 1 46.2%, 2 31.1%, 0 22.7% | 4.3% |
| Risk | 0.59 of 2 | 1 51.7%, 0 44.6%, 2 3.8% | 20.0% |
| Worth backporting | 1.24 of 2 | 2 44.0%, 1 35.9%, 0 20.2% | 4.4% |
Download
For cweagans/composer-patches, choose a version below and download the bundle. Copy its magento2-40388/ folder into patches/composer/, merge composer.patches.json into composer.json, then run composer install. Test files are always removed; paths are relative to each package root, using the default -p1 level.
Bundle README (what the ZIP ships)
# magento2-40388 Community fix merged upstream into magento/magento2, adapted by magento.watch. This is not a patch published by Adobe. Pull request: https://github.com/magento/magento2/pull/40388 Issue: https://github.com/magento/magento2/issues/40399 Author: @rogerdz Source commit: 0436e467895eba23d310c3c4cee0594e17137d95 Modifications: test files and documentation removed, paths rewritten relative to each Composer package. Licence: OSL-3.0 / AFL-3.0, as the original Magento Open Source code. Maintainer: Łukasz Bajsarowicz (@lbajsarowicz)
Licence: Magento Open Source code under OSL-3.0 and AFL-3.0. The bundle carries the original author, source commit and the list of modifications.
