From 53c732150e2bddb3211e07f2624378278cf0db80 Mon Sep 17 00:00:00 2001 From: "tom@aligent.com.au" Date: Wed, 21 Feb 2018 14:05:55 +1030 Subject: [PATCH 1/2] Remove forced setting of cache_lifetime to false in constructor and set default cache_lifetime to 3600 --- app/code/Magento/Theme/Block/Html/Footer.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Theme/Block/Html/Footer.php b/app/code/Magento/Theme/Block/Html/Footer.php index 4cd63462ec754..cdb350336f38f 100644 --- a/app/code/Magento/Theme/Block/Html/Footer.php +++ b/app/code/Magento/Theme/Block/Html/Footer.php @@ -57,7 +57,6 @@ protected function _construct() { $this->addData( [ - 'cache_lifetime' => false, 'cache_tags' => [\Magento\Store\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG], ] ); @@ -123,4 +122,14 @@ public function getIdentities() { return [\Magento\Store\Model\Store::CACHE_TAG, \Magento\Cms\Model\Block::CACHE_TAG]; } + + /** + * Get block cache life time + * + * @return int + */ + protected function getCacheLifetime() + { + return parent::getCacheLifetime() ?: 3600; + } } From 24078453b209bf36374840d79e82824eb37ad160 Mon Sep 17 00:00:00 2001 From: nmalevanec Date: Thu, 22 Feb 2018 13:49:09 +0200 Subject: [PATCH 2/2] Remove forced setting of cache_lifetime to false in constructor and set default cache_lifetime to 3600 Unit test. --- .../Theme/Test/Unit/Block/Html/FooterTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/app/code/Magento/Theme/Test/Unit/Block/Html/FooterTest.php b/app/code/Magento/Theme/Test/Unit/Block/Html/FooterTest.php index 8451e9c5aee6a..52175cc669bbd 100644 --- a/app/code/Magento/Theme/Test/Unit/Block/Html/FooterTest.php +++ b/app/code/Magento/Theme/Test/Unit/Block/Html/FooterTest.php @@ -30,4 +30,18 @@ public function testGetIdentities() $this->block->getIdentities() ); } + + /** + * Check Footer block has cache lifetime. + * + * @throws \ReflectionException + * @return void + */ + public function testGetCacheLifetime() + { + $reflection = new \ReflectionClass($this->block); + $method = $reflection->getMethod('getCacheLifetime'); + $method->setAccessible(true); + $this->assertEquals(3600, $method->invoke($this->block)); + } }