fix: Relative time may not be cached if specified in CacheHelper duration

This commit is contained in:
Koji Tanaka 2023-01-15 12:44:44 +09:00 committed by Kamil Wylegala
parent 1409ea3dda
commit 3acfb1da49
3 changed files with 1 additions and 12 deletions

View file

@ -1605,12 +1605,6 @@ class DispatcherTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testFullPageCachingDispatch($url) { 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.disable', false);
Configure::write('Cache.check', true); Configure::write('Cache.check', true);
Configure::write('debug', 2); Configure::write('debug', 2);

View file

@ -139,11 +139,6 @@ class CacheHelperTest extends CakeTestCase {
* @return void * @return void
*/ */
public function testLayoutCacheParsingNoTagsInViewWithRelativeDuration() { 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->cache_parsing();
$this->Controller->request->addParams(array( $this->Controller->request->addParams(array(
'controller' => 'cache_test', 'controller' => 'cache_test',

View file

@ -149,7 +149,7 @@ class CacheHelper extends AppHelper {
$cacheTime = $cacheAction; $cacheTime = $cacheAction;
} }
if ($cacheTime && $cacheTime > 0) { if ($cacheTime && ($cacheTime > 0 || isset(date_parse($cacheTime)['relative']))) {
$cached = $this->_parseOutput($out); $cached = $this->_parseOutput($out);
try { try {
$this->_writeFile($cached, $cacheTime, $useCallbacks); $this->_writeFile($cached, $cacheTime, $useCallbacks);