Skip to content

Commit bcf6acf

Browse files
committed
Use cache collector API from v13.3 as replacement for TSFE->cacheExpires
1 parent 7322049 commit bcf6acf

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

Classes/Hooks/PageLoadedFromCacheHook.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,17 @@ public function handleEvent(AfterTypoScriptDeterminedEvent $event): void
7272
return;
7373
}
7474

75-
// @todo This is ugly because $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] was removed in v13 without replacement,
76-
// and TSFE does not provide public access to current cache expiry timestamp
77-
$cacheExpires = \Closure::bind(static fn() => $tsfe->cacheExpires, null, TypoScriptFrontendController::class);
78-
$lifetime = $cacheExpires()- $context->getPropertyFromAspect('date', 'timestamp');
75+
$cacheCollector = $request->getAttribute('frontend.cache.collector');
76+
// => 13.3
77+
if ($cacheCollector !== null) {
78+
$lifetime = $cacheCollector->resolveLifetime();
79+
} else {
80+
// @todo This is ugly because $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['pageLoadedFromCache'] was removed in v13.0 without replacement,
81+
// and TSFE does not provide public access to current cache expiry timestamp
82+
$cacheExpires = \Closure::bind(static fn() => $tsfe->cacheExpires, null, TypoScriptFrontendController::class);
83+
$lifetime = $cacheExpires() - $context->getPropertyFromAspect('date', 'timestamp');
84+
}
85+
7986
$this->nginxCache->set(md5($uri), $uri, $pageCacheTags, $lifetime);
8087
}
8188

0 commit comments

Comments
 (0)