From 3acfb1da49fff7fd889dfb3b71627f4bdb5f8086 Mon Sep 17 00:00:00 2001 From: Koji Tanaka Date: Sun, 15 Jan 2023 12:44:44 +0900 Subject: [PATCH] fix: Relative time may not be cached if specified in CacheHelper duration --- lib/Cake/Test/Case/Routing/DispatcherTest.php | 6 ------ lib/Cake/Test/Case/View/Helper/CacheHelperTest.php | 5 ----- lib/Cake/View/Helper/CacheHelper.php | 2 +- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/lib/Cake/Test/Case/Routing/DispatcherTest.php b/lib/Cake/Test/Case/Routing/DispatcherTest.php index 7b8f36f78..08d45e46f 100644 --- a/lib/Cake/Test/Case/Routing/DispatcherTest.php +++ b/lib/Cake/Test/Case/Routing/DispatcherTest.php @@ -1605,12 +1605,6 @@ class DispatcherTest extends CakeTestCase { * @return void */ public function testFullPageCachingDispatch($url) { - // PHP 8.0+ has a bug in which the expiration date is not cached - // if the expiration date is specified as a relative time. - if (PHP_MAJOR_VERSION >= 8) { - $this->markTestIncomplete('If an expiration date is specified as a relative time, it cannot be cached.'); - } - Configure::write('Cache.disable', false); Configure::write('Cache.check', true); Configure::write('debug', 2); diff --git a/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php b/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php index 6f375b9d9..1d276f8be 100644 --- a/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php +++ b/lib/Cake/Test/Case/View/Helper/CacheHelperTest.php @@ -139,11 +139,6 @@ class CacheHelperTest extends CakeTestCase { * @return void */ public function testLayoutCacheParsingNoTagsInViewWithRelativeDuration() { - // PHP 8.0+ has a bug in which the expiration date is not cached - // if the expiration date is specified as a relative time. - if (PHP_MAJOR_VERSION >= 8) { - $this->markTestIncomplete('If an expiration date is specified as a relative time, it cannot be cached.'); - } $this->Controller->cache_parsing(); $this->Controller->request->addParams(array( 'controller' => 'cache_test', diff --git a/lib/Cake/View/Helper/CacheHelper.php b/lib/Cake/View/Helper/CacheHelper.php index 618c2f82f..2cf7e89d0 100644 --- a/lib/Cake/View/Helper/CacheHelper.php +++ b/lib/Cake/View/Helper/CacheHelper.php @@ -149,7 +149,7 @@ class CacheHelper extends AppHelper { $cacheTime = $cacheAction; } - if ($cacheTime && $cacheTime > 0) { + if ($cacheTime && ($cacheTime > 0 || isset(date_parse($cacheTime)['relative']))) { $cached = $this->_parseOutput($out); try { $this->_writeFile($cached, $cacheTime, $useCallbacks);