Skip to content

Commit

Permalink
Avoid deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
bnf committed Jan 30, 2024
1 parent 68be673 commit f14e48e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 3 additions & 3 deletions Classes/Hooks/PageLoadedFromCacheHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -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);
}
Expand Down
7 changes: 5 additions & 2 deletions Classes/Hooks/SetPageCacheHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
);
Expand Down

0 comments on commit f14e48e

Please sign in to comment.