Skip to content

Commit d95fba6

Browse files
Merge remote-tracking branch '40112/patch-13' into comprs_oct
2 parents 1d22647 + 53d4859 commit d95fba6

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

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

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ class Layout extends \Magento\Framework\Simplexml\Config implements \Magento\Fra
194194
*/
195195
private ResponseHttp $response;
196196

197+
/**
198+
* Property used to cache the results of the isCacheable() method.
199+
*
200+
* @var bool|null
201+
*/
202+
private ?bool $isCacheableCache = null;
203+
197204
/**
198205
* @param ProcessorFactory $processorFactory
199206
* @param ManagerInterface $eventManager
@@ -349,6 +356,7 @@ public function generateXml()
349356
public function generateElements()
350357
{
351358
\Magento\Framework\Profiler::start(__CLASS__ . '::' . __METHOD__);
359+
$this->isCacheableCache = null;
352360
$cacheId = 'structure_' . $this->getUpdate()->getCacheId();
353361
$result = $this->cache->load($cacheId);
354362
if ($result) {
@@ -1182,18 +1190,22 @@ protected function _prepareMessageGroup($messageGroups)
11821190
*/
11831191
public function isCacheable()
11841192
{
1185-
$this->build();
1186-
$elements = $this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]');
1187-
$cacheable = $this->cacheable;
1188-
foreach ($elements as $element) {
1189-
$blockName = $element->getBlockName();
1190-
if ($blockName !== false && $this->structure->hasElement($blockName)) {
1191-
$cacheable = false;
1192-
break;
1193+
if ($this->isCacheableCache === null) {
1194+
$this->build();
1195+
$elements = $this->getXml()->xpath('//' . Element::TYPE_BLOCK . '[@cacheable="false"]');
1196+
$cacheable = $this->cacheable;
1197+
foreach ($elements as $element) {
1198+
$blockName = $element->getBlockName();
1199+
if ($blockName !== false && $this->structure->hasElement($blockName)) {
1200+
$cacheable = false;
1201+
break;
1202+
}
11931203
}
1204+
1205+
$this->isCacheableCache = $cacheable;
11941206
}
11951207

1196-
return $cacheable;
1208+
return $this->isCacheableCache;
11971209
}
11981210

11991211
/**

0 commit comments

Comments
 (0)