From 3afb8f46ccc1d6d9131eaa2b8914df5b8912bdde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Lochm=C3=BCller?= Date: Wed, 20 Mar 2024 20:22:38 +0100 Subject: [PATCH] Add todo for v13 migration --- Classes/Cache/Listener/StaticCacheableListener.php | 2 ++ Classes/Cache/Rule/NoNoCache.php | 1 + Classes/Middleware/GenerateMiddleware.php | 6 ++++++ 3 files changed, 9 insertions(+) diff --git a/Classes/Cache/Listener/StaticCacheableListener.php b/Classes/Cache/Listener/StaticCacheableListener.php index 73409911323..694890948e8 100644 --- a/Classes/Cache/Listener/StaticCacheableListener.php +++ b/Classes/Cache/Listener/StaticCacheableListener.php @@ -24,8 +24,10 @@ public function __invoke(CacheRuleEvent $event): void { if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) { if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() >= 13) { + /* @phpstan-ignore-next-line */ $isStaticCacheble = $GLOBALS['TSFE']->isStaticCacheble($event->getRequest()); } else { + /* @phpstan-ignore-next-line */ $isStaticCacheble = $GLOBALS['TSFE']->isStaticCacheble(); } if(!$isStaticCacheble) { diff --git a/Classes/Cache/Rule/NoNoCache.php b/Classes/Cache/Rule/NoNoCache.php index 8349338a737..9665d526f0d 100644 --- a/Classes/Cache/Rule/NoNoCache.php +++ b/Classes/Cache/Rule/NoNoCache.php @@ -18,6 +18,7 @@ class NoNoCache extends AbstractRule public function checkRule(ServerRequestInterface $request, array &$explanation, bool &$skipProcessing): void { $tsfe = $GLOBALS['TSFE'] ?? null; + /* @phpstan-ignore-next-line */ if ($tsfe instanceof TypoScriptFrontendController && $tsfe->no_cache) { $explanation[__CLASS__] = 'config.no_cache is true'; } diff --git a/Classes/Middleware/GenerateMiddleware.php b/Classes/Middleware/GenerateMiddleware.php index 69e8027c31b..9c7cbf1228e 100644 --- a/Classes/Middleware/GenerateMiddleware.php +++ b/Classes/Middleware/GenerateMiddleware.php @@ -18,6 +18,8 @@ use SFC\Staticfilecache\Service\DateTimeService; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; +use TYPO3\CMS\Frontend\Event\AfterCachedPageIsPersistedEvent; +use TYPO3\CMS\Frontend\Event\ModifyCacheLifetimeForPageEvent; class GenerateMiddleware implements MiddlewareInterface { @@ -82,6 +84,10 @@ protected function calculateLifetime(TypoScriptFrontendController $tsfe): int // $this->logger->warning('TSFE to not contains a valid page record?! Please check: https://github.com/lochmueller/staticfilecache/issues/150'); return 0; } + + // @todo migrate for v13 to Events + // Check ModifyCacheLifetimeForPageEvent & AfterCachedPageIsPersistedEvent + $timeOutTime = $tsfe->get_cache_timeout(); // If page has a endtime before the current timeOutTime, use it instead: