Skip to content

Commit 69a550d

Browse files
authored
ENGCOM-5631: Extract handles from layout updates before layout merge step. #23918
2 parents 1579377 + 2f8cf3c commit 69a550d

File tree

1 file changed

+24
-0
lines changed
  • lib/internal/Magento/Framework/View/Model/Layout

1 file changed

+24
-0
lines changed

lib/internal/Magento/Framework/View/Model/Layout/Merge.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
* Layout merge model
1919
* @SuppressWarnings(PHPMD.TooManyFields)
2020
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
21+
* @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
2122
*/
2223
class Merge implements \Magento\Framework\View\Layout\ProcessorInterface
2324
{
@@ -462,6 +463,8 @@ public function load($handles = [])
462463
return $this;
463464
}
464465

466+
$this->extractHandlers();
467+
465468
foreach ($this->getHandles() as $handle) {
466469
$this->_merge($handle);
467470
}
@@ -951,4 +954,25 @@ public function getCacheId()
951954
// phpcs:ignore Magento2.Security.InsecureFunction
952955
return $this->generateCacheId(md5(implode('|', array_merge($this->getHandles(), $layoutCacheKeys))));
953956
}
957+
958+
/**
959+
* Walk all updates and extract handles before the merge step.
960+
*/
961+
private function extractHandlers(): void
962+
{
963+
foreach ($this->updates as $update) {
964+
$updateXml = null;
965+
966+
try {
967+
$updateXml = $this->_loadXmlString($update);
968+
// phpcs:ignore Magento2.CodeAnalysis.EmptyBlock
969+
} catch (\Exception $exception) {
970+
// ignore invalid
971+
}
972+
973+
if ($updateXml && strtolower($updateXml->getName()) == 'update' && isset($updateXml['handle'])) {
974+
$this->addHandle((string)$updateXml['handle']);
975+
}
976+
}
977+
}
954978
}

0 commit comments

Comments
 (0)