Skip to content

Commit

Permalink
Use cache collector API from v13.3 as replacement for TSFE->cacheExpires
Browse files Browse the repository at this point in the history
  • Loading branch information
bnf committed Oct 15, 2024
1 parent 7322049 commit bcf6acf
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions Classes/Hooks/PageLoadedFromCacheHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,17 @@ public function handleEvent(AfterTypoScriptDeterminedEvent $event): void
return;
}

// @todo This is ugly because $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] was removed in v13 without replacement,
// and TSFE does not provide public access to current cache expiry timestamp
$cacheExpires = \Closure::bind(static fn() => $tsfe->cacheExpires, null, TypoScriptFrontendController::class);
$lifetime = $cacheExpires()- $context->getPropertyFromAspect('date', 'timestamp');
$cacheCollector = $request->getAttribute('frontend.cache.collector');
// => 13.3
if ($cacheCollector !== null) {
$lifetime = $cacheCollector->resolveLifetime();
} else {
// @todo This is ugly because $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] was removed in v13.0 without replacement,
// and TSFE does not provide public access to current cache expiry timestamp
$cacheExpires = \Closure::bind(static fn() => $tsfe->cacheExpires, null, TypoScriptFrontendController::class);
$lifetime = $cacheExpires() - $context->getPropertyFromAspect('date', 'timestamp');
}

$this->nginxCache->set(md5($uri), $uri, $pageCacheTags, $lifetime);
}

Expand Down

0 comments on commit bcf6acf

Please sign in to comment.