{"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,"inclusion":"confirmed-issue","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":"e6db289d6aec41acc370881d923ed52ecc78e76b213d0dfe0048f987099d9f91","isBugfix":0.876,"changeKind":{"choice":"bugfix","probabilities":{"bugfix":0.8972,"feature":0.01,"refactor":0.0672,"tests_only":0.0146,"docs_only":0.0054,"dependency":0.0056},"confidence":0.7718},"scope":{"score":0.5753,"probabilities":{"0":0.4817,"1":0.4613,"2":0.057},"confidence":0.1721},"risk":{"score":0.2125,"probabilities":{"0":0.8227,"1":0.1422,"2":0.0351},"confidence":0.5473},"area":{"choice":"catalog","probabilities":{"catalog":0.686,"checkout":0.0077,"customer":0.0055,"admin":0.0156,"graphql_api":0.2412,"framework":0.0157,"frontend":0.0135,"other":0.0148},"confidence":0.4626},"securityRelevant":0.0061,"reportedVersion":{"choice":"unspecified","probabilities":{"2.4.0":0.0106,"2.4.0-p1":0.0058,"2.4.1":0.0045,"2.4.1-p1":0.0041,"2.4.2":0.0062,"2.4.2-p1":0.006,"2.4.2-p2":0.0076,"2.4.3":0.0115,"2.4.3-p1":0.0111,"2.4.3-p2":0.0105,"2.4.3-p3":0.007,"2.4.4":0.0145,"2.4.4-p1":0.0104,"2.4.4-p10":0.0068,"2.4.4-p11":0.0081,"2.4.4-p12":0.0071,"2.4.4-p13":0.0074,"2.4.4-p14":0.0082,"2.4.4-p15":0.006,"2.4.4-p16":0.0069,"2.4.4-p17":0.0057,"2.4.4-p18":0.0052,"2.4.4-p2":0.0033,"2.4.4-p3":0.004,"2.4.4-p4":0.0047,"2.4.4-p5":0.0044,"2.4.4-p6":0.0044,"2.4.4-p7":0.0046,"2.4.4-p8":0.0038,"2.4.4-p9":0.0045,"2.4.5":0.0087,"2.4.5-p1":0.0088,"2.4.5-p10":0.0052,"2.4.5-p11":0.0086,"2.4.5-p12":0.0069,"2.4.5-p13":0.0062,"2.4.5-p14":0.0064,"2.4.5-p15":0.0049,"2.4.5-p16":0.0063,"2.4.5-p17":0.0059,"2.4.5-p2":0.0039,"2.4.5-p3":0.0047,"2.4.5-p4":0.0058,"2.4.5-p5":0.0049,"2.4.5-p6":0.0048,"2.4.5-p7":0.0053,"2.4.5-p8":0.0043,"2.4.5-p9":0.0036,"2.4.6":0.0138,"2.4.6-p1":0.0106,"2.4.6-p10":0.007,"2.4.6-p11":0.0083,"2.4.6-p12":0.0081,"2.4.6-p13":0.0073,"2.4.6-p14":0.0067,"2.4.6-p15":0.0053,"2.4.6-p2":0.0038,"2.4.6-p3":0.006,"2.4.6-p4":0.0074,"2.4.6-p5":0.0061,"2.4.6-p6":0.0059,"2.4.6-p7":0.0064,"2.4.6-p8":0.005,"2.4.6-p9":0.0041,"2.4.7":0.0103,"2.4.7-p1":0.0081,"2.4.7-p10":0.006,"2.4.7-p2":0.0061,"2.4.7-p3":0.0093,"2.4.7-p4":0.0111,"2.4.7-p5":0.0092,"2.4.7-p6":0.011,"2.4.7-p7":0.0084,"2.4.7-p8":0.0075,"2.4.7-p9":0.0048,"2.4.8":0.011,"2.4.8-p1":0.0095,"2.4.8-p2":0.0111,"2.4.8-p3":0.0113,"2.4.8-p4":0.0118,"2.4.8-p5":0.0095,"2.4.9":0.0117,"unspecified":0.4104},"confidence":0.1631},"backportWorthy":{"score":0.9598,"probabilities":{"0":0.3359,"1":0.3685,"2":0.2956},"confidence":0.004}},"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"}