{"data":{"id":"magento2-37570","source":"github-pr","sourceRef":"magento/magento2#37570","title":"Avoid lots of uncessary exceptions during layout XML merge loading","pr":{"number":37570,"url":"https://github.com/magento/magento2/pull/37570","author":"amenk","mergedAt":"2025-06-26T06:32:13Z","mergeCommit":"824b8b141dea85eb6e2cd1cc1782db182d2ecfdb","headCommit":"89c19806dad90e0b5345148ef5d6bc6f6421b602","baseRef":"2.4-develop","diffSha256":"ccd6babc1cd9bdd97dbe27300ef32dff618e99bf4f099f3d3ad1ac6f02167915"},"issues":[{"number":39877,"url":"https://github.com/magento/magento2/issues/39877","title":"[Issue] Avoid lots of uncessary exceptions during layout XML merge loading","labels":["Area: Framework","Component: Frontend","Issue: Confirmed","Priority: P3","Progress: done","Reported on 2.4.x","Reproduced on 2.4.x"],"kind":"pr-derived"}],"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/framework"],"files":[{"path":"lib/internal/Magento/Framework/View/Model/Layout/Merge.php","change":"modified","package":"magento/framework"}],"stripped":{"tests":[],"docs":[],"outsideCode":[]},"linesChanged":29,"mergeBatched":false,"excluded":null,"sections":{"description":"* Introduce a new function (for B/C compat we don't overwrite the protected _loadXmlString) to load and not throw an exception\n* Use it in extract handlers -> no need to catch the exception any more","stepsToReproduce":"1. Install the sentry plugin\n2. Have some invalid XML there\n3. Exception is reported, even it is not necessary\n\n### Reason\n\nWhen using tools like Sentry, because of there inner workings, such exceptions still might be reported. While this is not exactly the root cause, it's always cleaner to not throw an exception and immediately catch it, if invalid cases can happen often.\n\nThis might even improve performance a bit and improves developer's experience.\n\n### Remarks\n\nThere seems some invalid XML at that place in the code happen quite often - it might be also interesting to check if that can be avoided.\n\nThis is a simple, trivial change to the code and should not break anything, so hopefully this can get triaged quickly and without to much back-and-forth about the testing procedure :-)","expectedResult":null,"actualResult":null,"source":"pr"},"signatures":["3. Exception is reported, even it is not necessary"],"labels":{"area":["Framework"],"component":["Frontend"],"priority":"P3","severity":null,"reportedOn":["2.4.x"]},"categories":[],"triage":{"model":"@cf/cloudflare/clef","requestHash":"e8e007c917939a01c7152919ae010b4db006c8af08932f19a35ffde88e6eb288","isBugfix":0.4562,"changeKind":{"choice":"refactor","probabilities":{"bugfix":0.4668,"feature":0.0394,"refactor":0.4692,"tests_only":0.009,"docs_only":0.0071,"dependency":0.0085},"confidence":0.3278},"scope":{"score":0.8469,"probabilities":{"0":0.2868,"1":0.5796,"2":0.1336},"confidence":0.154},"risk":{"score":0.3409,"probabilities":{"0":0.6934,"1":0.2724,"2":0.0342},"confidence":0.3342},"area":{"choice":"framework","probabilities":{"catalog":0.0122,"checkout":0.0097,"customer":0.008,"admin":0.0203,"graphql_api":0.0069,"framework":0.7323,"frontend":0.193,"other":0.0176},"confidence":0.5138},"securityRelevant":0.008,"reportedVersion":{"choice":"unspecified","probabilities":{"2.4.0":0.0051,"2.4.0-p1":0.005,"2.4.1":0.0048,"2.4.1-p1":0.0047,"2.4.2":0.0058,"2.4.2-p1":0.0058,"2.4.2-p2":0.0063,"2.4.3":0.0103,"2.4.3-p1":0.0109,"2.4.3-p2":0.012,"2.4.3-p3":0.007,"2.4.4":0.0102,"2.4.4-p1":0.0077,"2.4.4-p10":0.0071,"2.4.4-p11":0.0083,"2.4.4-p12":0.0072,"2.4.4-p13":0.0068,"2.4.4-p14":0.0082,"2.4.4-p15":0.0066,"2.4.4-p16":0.0071,"2.4.4-p17":0.006,"2.4.4-p18":0.0056,"2.4.4-p2":0.0033,"2.4.4-p3":0.0036,"2.4.4-p4":0.0036,"2.4.4-p5":0.0046,"2.4.4-p6":0.0042,"2.4.4-p7":0.0043,"2.4.4-p8":0.0057,"2.4.4-p9":0.0044,"2.4.5":0.0132,"2.4.5-p1":0.0105,"2.4.5-p10":0.0077,"2.4.5-p11":0.0106,"2.4.5-p12":0.0093,"2.4.5-p13":0.0099,"2.4.5-p14":0.0087,"2.4.5-p15":0.0071,"2.4.5-p16":0.008,"2.4.5-p17":0.0079,"2.4.5-p2":0.0041,"2.4.5-p3":0.0056,"2.4.5-p4":0.0056,"2.4.5-p5":0.0055,"2.4.5-p6":0.0063,"2.4.5-p7":0.0071,"2.4.5-p8":0.0054,"2.4.5-p9":0.0052,"2.4.6":0.0205,"2.4.6-p1":0.0166,"2.4.6-p10":0.0092,"2.4.6-p11":0.0128,"2.4.6-p12":0.0121,"2.4.6-p13":0.011,"2.4.6-p14":0.0114,"2.4.6-p15":0.0102,"2.4.6-p2":0.0051,"2.4.6-p3":0.0076,"2.4.6-p4":0.0079,"2.4.6-p5":0.0075,"2.4.6-p6":0.0082,"2.4.6-p7":0.0078,"2.4.6-p8":0.0065,"2.4.6-p9":0.0057,"2.4.7":0.0166,"2.4.7-p1":0.0121,"2.4.7-p10":0.0104,"2.4.7-p2":0.009,"2.4.7-p3":0.0127,"2.4.7-p4":0.0147,"2.4.7-p5":0.0112,"2.4.7-p6":0.0125,"2.4.7-p7":0.0129,"2.4.7-p8":0.0104,"2.4.7-p9":0.0062,"2.4.8":0.0167,"2.4.8-p1":0.0144,"2.4.8-p2":0.0172,"2.4.8-p3":0.0171,"2.4.8-p4":0.014,"2.4.8-p5":0.0145,"2.4.9":0.0183,"unspecified":0.2691},"confidence":0.069},"backportWorthy":{"score":0.9815,"probabilities":{"0":0.3295,"1":0.3595,"2":0.311},"confidence":0.0018}},"curated":{"title":"Extract handlers load layout XML without an exception for invalid XML","description":"Merge::extractHandlers used _loadXmlString for each layout update and had to catch the exception for invalid XML, and tools like Sentry still might report such exceptions. The change adds a protected _safeLoadXmlString function that uses simplexml_load_string with LIBXML_NOWARNING | LIBXML_NOERROR to return false if XML was invalid, and extractHandlers now uses it with no catch.","categories":[],"author":"claude-code/opus-5.5","date":"2026-10-06","reviewedBy":null},"tests":null},"_documentation":"https://magento.watch/api","_description":"Upstream fix magento2-37570 details"}