From b59dc722059f3a87716a41dc0f5ae62ec297fb69 Mon Sep 17 00:00:00 2001 From: Lukasz Bajsarowicz Date: Sat, 4 Jul 2020 02:19:41 +0200 Subject: [PATCH] Avoid multiple calls and config fetch --- app/code/Magento/PageCache/Model/Config.php | 2 +- app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/code/Magento/PageCache/Model/Config.php b/app/code/Magento/PageCache/Model/Config.php index 10ae41be21d4d..bf144cc46637e 100644 --- a/app/code/Magento/PageCache/Model/Config.php +++ b/app/code/Magento/PageCache/Model/Config.php @@ -121,7 +121,7 @@ public function __construct( */ public function getType() { - return $this->_scopeConfig->getValue(self::XML_PAGECACHE_TYPE); + return (int)$this->_scopeConfig->getValue(self::XML_PAGECACHE_TYPE); } /** diff --git a/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php index 762f393f2a1b9..9e22c95232ee0 100644 --- a/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php +++ b/app/code/Magento/PageCache/Model/Layout/LayoutPlugin.php @@ -74,10 +74,11 @@ public function afterGetOutput(Layout $subject, $result) { if ($subject->isCacheable() && $this->config->isEnabled()) { $tags = [[]]; + $isVarnish = $this->config->getType() === Config::VARNISH; + foreach ($subject->getAllBlocks() as $block) { if ($block instanceof IdentityInterface) { $isEsiBlock = $block->getTtl() > 0; - $isVarnish = $this->config->getType() == Config::VARNISH; if ($isVarnish && $isEsiBlock) { continue; }