{"data":{"id":"magento2-39681","source":"github-pr","sourceRef":"magento/magento2#39681","title":"Product Collection - addMediaGalleryData calls getSize when the collection maybe or will be loaded (Can use count to avoid an extra DB query)","pr":{"number":39681,"url":"https://github.com/magento/magento2/pull/39681","author":"Himsoft","mergedAt":"2025-04-16T11:05:48Z","mergeCommit":"5388de0c4b8dc94569c15ecc18e6ded30c1bb82a","headCommit":"fb61e3b1676ffa5c311bf52057b8ce7cc834d6cf","baseRef":"2.4-develop","diffSha256":"37f4e788f7832f07766aed935053f2267a268a051fcc9e4a685e5b402aa514f5"},"issues":[{"number":39111,"url":"https://github.com/magento/magento2/issues/39111","title":"Product Collection - addMediaGalleryData calls getSize when the collection maybe or will be loaded (Can use count to avoid an extra DB query)","labels":["Area: Product","Component: MediaGallery","Issue: Confirmed","Priority: P2","Progress: done","Reported on 2.4.x","Reproduced on 2.4.x","Triage: Dev.Experience"],"kind":"human"}],"fixedIn":"2.4.9","containingTags":["2.4.9"],"reportedOn":null,"codeMatch":{"2.4.6":"clean","2.4.6-p1":"clean","2.4.6-p2":"clean","2.4.6-p3":"clean","2.4.6-p4":"clean","2.4.6-p5":"clean","2.4.6-p6":"clean","2.4.6-p7":"clean","2.4.6-p8":"clean","2.4.6-p9":"clean","2.4.6-p10":"clean","2.4.6-p11":"clean","2.4.6-p12":"clean","2.4.6-p13":"clean","2.4.6-p14":"clean","2.4.6-p15":"clean","2.4.7":"clean","2.4.7-p1":"clean","2.4.7-p2":"clean","2.4.7-p3":"clean","2.4.7-p4":"clean","2.4.7-p5":"clean","2.4.7-p6":"clean","2.4.7-p7":"clean","2.4.7-p8":"clean","2.4.7-p9":"clean","2.4.7-p10":"clean","2.4.8":"clean","2.4.8-p1":"clean","2.4.8-p2":"clean","2.4.8-p3":"clean","2.4.8-p4":"clean","2.4.8-p5":"clean","2.4.9":"conflict"},"affectedVersions":["2.4.6","2.4.6-p1","2.4.6-p2","2.4.6-p3","2.4.6-p4","2.4.6-p5","2.4.6-p6","2.4.6-p7","2.4.6-p8","2.4.6-p9","2.4.6-p10","2.4.6-p11","2.4.6-p12","2.4.6-p13","2.4.6-p14","2.4.6-p15","2.4.7","2.4.7-p1","2.4.7-p2","2.4.7-p3","2.4.7-p4","2.4.7-p5","2.4.7-p6","2.4.7-p7","2.4.7-p8","2.4.7-p9","2.4.7-p10","2.4.8","2.4.8-p1","2.4.8-p2","2.4.8-p3","2.4.8-p4","2.4.8-p5"],"components":["magento/module-catalog"],"files":[{"path":"app/code/Magento/Catalog/Model/ResourceModel/Product/Collection.php","change":"modified","package":"magento/module-catalog"}],"stripped":{"tests":["app/code/Magento/Catalog/Test/Unit/Model/ResourceModel/Product/CollectionTest.php"],"docs":[],"outsideCode":[]},"linesChanged":4,"mergeBatched":false,"excluded":null,"sections":{"description":"getSize is called on a loaded paginated collection to check if it has data.","stepsToReproduce":"1. Enable dev query log\n1. This should be reproducible by calling the products GQL call with the media*gallery/media_gallery*entries field selected.\n1. The count call should be in the query log, traced to addMediaGalleryData","expectedResult":"getSize is not called on a loaded product collection. (When the non-paginated count is not needed).","actualResult":"getSize is called on a loaded paginated collection to check if it has data.","source":"issue"},"signatures":[],"labels":{"area":["Product"],"component":["MediaGallery"],"priority":"P2","severity":null,"reportedOn":["2.4.x"]},"categories":["Catalog/Product"],"triage":{"model":"@cf/cloudflare/clef","requestHash":"ec017e57c06545904a03732297ca12d904fba7b9f0638e1f918066c71183d490","isBugfix":0.8355,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.8671,"feature":0.009,"refactor":0.0521,"tests_only":0.0138,"docs_only":0.0054,"dependency":0.0051,"cleanup":0.0475},"confidence":0.7167},"scope":{"score":0.5758,"probabilities":{"0":0.4822,"1":0.4598,"2":0.058},"confidence":0.171},"risk":{"score":0.2347,"probabilities":{"0":0.8037,"1":0.1578,"2":0.0385},"confidence":0.5086},"area":{"choice":"catalog","probabilities":{"catalog":0.6718,"checkout":0.0082,"customer":0.0059,"admin":0.0163,"graphql_api":0.25,"framework":0.0177,"frontend":0.0137,"other":0.0164},"confidence":0.4457},"securityRelevant":0.0065,"reportedVersion":{"choice":"unspecified","probabilities":{"2.4.0":0.0106,"2.4.0-p1":0.0055,"2.4.1":0.0045,"2.4.1-p1":0.0042,"2.4.2":0.0062,"2.4.2-p1":0.0056,"2.4.2-p2":0.008,"2.4.3":0.0119,"2.4.3-p1":0.0117,"2.4.3-p2":0.01,"2.4.3-p3":0.0072,"2.4.4":0.0139,"2.4.4-p1":0.0101,"2.4.4-p10":0.0068,"2.4.4-p11":0.0083,"2.4.4-p12":0.0075,"2.4.4-p13":0.0077,"2.4.4-p14":0.0085,"2.4.4-p15":0.006,"2.4.4-p16":0.0067,"2.4.4-p17":0.0055,"2.4.4-p18":0.0053,"2.4.4-p2":0.0035,"2.4.4-p3":0.004,"2.4.4-p4":0.0053,"2.4.4-p5":0.0051,"2.4.4-p6":0.0049,"2.4.4-p7":0.0053,"2.4.4-p8":0.0046,"2.4.4-p9":0.005,"2.4.5":0.0092,"2.4.5-p1":0.0086,"2.4.5-p10":0.0056,"2.4.5-p11":0.0086,"2.4.5-p12":0.0075,"2.4.5-p13":0.0068,"2.4.5-p14":0.0065,"2.4.5-p15":0.0049,"2.4.5-p16":0.0061,"2.4.5-p17":0.0066,"2.4.5-p2":0.004,"2.4.5-p3":0.0047,"2.4.5-p4":0.0063,"2.4.5-p5":0.0047,"2.4.5-p6":0.0055,"2.4.5-p7":0.0058,"2.4.5-p8":0.0045,"2.4.5-p9":0.0037,"2.4.6":0.0137,"2.4.6-p1":0.0111,"2.4.6-p10":0.007,"2.4.6-p11":0.0091,"2.4.6-p12":0.0086,"2.4.6-p13":0.0081,"2.4.6-p14":0.0083,"2.4.6-p15":0.006,"2.4.6-p2":0.0043,"2.4.6-p3":0.0066,"2.4.6-p4":0.0076,"2.4.6-p5":0.0066,"2.4.6-p6":0.0063,"2.4.6-p7":0.007,"2.4.6-p8":0.0057,"2.4.6-p9":0.0044,"2.4.7":0.0097,"2.4.7-p1":0.0081,"2.4.7-p10":0.0075,"2.4.7-p2":0.0067,"2.4.7-p3":0.0099,"2.4.7-p4":0.0139,"2.4.7-p5":0.0097,"2.4.7-p6":0.0118,"2.4.7-p7":0.0088,"2.4.7-p8":0.0083,"2.4.7-p9":0.0047,"2.4.8":0.0105,"2.4.8-p1":0.0101,"2.4.8-p2":0.0109,"2.4.8-p3":0.0114,"2.4.8-p4":0.0111,"2.4.8-p5":0.0109,"2.4.9":0.0116,"unspecified":0.385},"confidence":0.1431},"backportWorthy":{"score":0.9307,"probabilities":{"0":0.3579,"1":0.3534,"2":0.2887},"confidence":0.0045}},"curated":{"title":"addMediaGalleryData runs getSize on an already loaded product collection","description":"Product Collection addMediaGalleryData calls getSize on a collection that is loaded already, for example in the products GQL call with media_gallery selected. The change calls count when the collection is loaded and getSize when it is not.","categories":["Catalog/Product"],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":{"2.4.8-p5":{"before":"fail","after":"pass","adapted":false,"runAt":"2026-10-06T09:20:10.432Z","releaseCommit":"870a22c63d9d9b68fa3297962e2d5d5841115814","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:20:10.432Z"}}},"2.4.7-p10":{"before":"fail","after":"pass","adapted":false,"runAt":"2026-10-06T09:29:24.218Z","releaseCommit":"72561bf80652f57cc642a03e2c9a51d74a285b14","suites":{"unit":{"before":"fail","after":"pass","runAt":"2026-10-06T09:29:24.218Z"}}}}},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-39681 details"}