From f14e48eae383ad511a6e67f3f3859c29a3445f47 Mon Sep 17 00:00:00 2001 From: Benjamin Franzke Date: Tue, 30 Jan 2024 14:11:10 +0100 Subject: [PATCH] Avoid deprecated methods --- Classes/Hooks/PageLoadedFromCacheHook.php | 6 +++--- Classes/Hooks/SetPageCacheHook.php | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Classes/Hooks/PageLoadedFromCacheHook.php b/Classes/Hooks/PageLoadedFromCacheHook.php index b105ace..40a2b80 100644 --- a/Classes/Hooks/PageLoadedFromCacheHook.php +++ b/Classes/Hooks/PageLoadedFromCacheHook.php @@ -53,9 +53,10 @@ public function loadedFromCache(array &$params, TypoScriptFrontendController $ts $request = $this->getServerRequest(); $uri = $this->getUri($request); + $context = GeneralUtility::makeInstance(Context::class); $cachable = ( - $tsfe->isStaticCacheble() && - $tsfe->doWorkspacePreview() === false && + $tsfe->isStaticCacheble($request) && + $context->getPropertyFromAspect('workspace', 'isOffline', false) === false && strpos($uri, '?') === false && $this->isAdminPanelVisible() === false && $this->isFrontendEditingActive($tsfe) === false && @@ -66,7 +67,6 @@ public function loadedFromCache(array &$params, TypoScriptFrontendController $ts return; } - $context = GeneralUtility::makeInstance(Context::class); $lifetime = $row['expires'] - $context->getPropertyFromAspect('date', 'timestamp'); $this->nginxCache->set(md5($uri), $uri, $nginxCacheTags, $lifetime); } diff --git a/Classes/Hooks/SetPageCacheHook.php b/Classes/Hooks/SetPageCacheHook.php index 923c4dd..f2c3885 100644 --- a/Classes/Hooks/SetPageCacheHook.php +++ b/Classes/Hooks/SetPageCacheHook.php @@ -20,6 +20,8 @@ use Psr\Container\ContainerInterface; use Psr\Http\Message\ServerRequestInterface; use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; +use TYPO3\CMS\Core\Context\Context; +use TYPO3\CMS\Core\Utility\GeneralUtility; class SetPageCacheHook { @@ -64,11 +66,12 @@ public function set(array $params, FrontendInterface $frontend): void $temp_content = (isset($data['temp_content']) && $data['temp_content']); $tsfe = $this->getTypoScriptFrontendController(); + $context = GeneralUtility::makeInstance(Context::class); $isLaterCachable = ( $temp_content === false && $tsfe !== null && - $tsfe->isStaticCacheble() && - $tsfe->doWorkspacePreview() === false && + $tsfe->isStaticCacheble($request) && + $context->getPropertyFromAspect('workspace', 'isOffline', false) === false && $this->isFrontendEditingActive($tsfe) === false && in_array('nginx_cache_ignore', $tags, true) === false );