Skip to content

Commit

Permalink
Fix isStaticCacheble call for TYPO3 v13
Browse files Browse the repository at this point in the history
  • Loading branch information
lochmueller committed Mar 20, 2024
1 parent a63dc72 commit 37fc64a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 42 deletions.
13 changes: 11 additions & 2 deletions Classes/Cache/Listener/StaticCacheableListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace SFC\Staticfilecache\Cache\Listener;

use SFC\Staticfilecache\Event\CacheRuleEvent;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController;

/**
Expand All @@ -20,8 +22,15 @@ class StaticCacheableListener
*/
public function __invoke(CacheRuleEvent $event): void
{
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController && !$GLOBALS['TSFE']->isStaticCacheble()) {
$event->addExplanation(__CLASS__, 'The page is not static cacheable via TypoScriptFrontend. Check the first Question on: https://github.com/lochmueller/staticfilecache/blob/master/Documentation/Faq/Index.rst');
if (($GLOBALS['TSFE'] ?? null) instanceof TypoScriptFrontendController) {
if (GeneralUtility::makeInstance(Typo3Version::class)->getMajorVersion() >= 13) {
$isStaticCacheble = $GLOBALS['TSFE']->isStaticCacheble($event->getRequest());

Check failure on line 27 in Classes/Cache/Listener/StaticCacheableListener.php

View workflow job for this annotation

GitHub Actions / build (8.1, 12)

Method TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::isStaticCacheble() invoked with 1 parameter, 0 required.

Check failure on line 27 in Classes/Cache/Listener/StaticCacheableListener.php

View workflow job for this annotation

GitHub Actions / build (8.2, 12)

Method TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController::isStaticCacheble() invoked with 1 parameter, 0 required.
} else {
$isStaticCacheble = $GLOBALS['TSFE']->isStaticCacheble();
}
if(!$isStaticCacheble) {
$event->addExplanation(__CLASS__, 'The page is not static cacheable via TypoScriptFrontend. Check the first Question on: https://github.com/lochmueller/staticfilecache/blob/master/Documentation/Faq/Index.rst');
}
}
}
}
35 changes: 0 additions & 35 deletions Classes/Cache/Rule/LoginDeniedConfiguration.php

This file was deleted.

5 changes: 0 additions & 5 deletions Classes/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use TYPO3\CMS\Core\Configuration\Exception\ExtensionConfigurationPathDoesNotExistException;
use SFC\Staticfilecache\Cache\RemoteFileBackend;
use SFC\Staticfilecache\Cache\Rule\Enable;
use SFC\Staticfilecache\Cache\Rule\LoginDeniedConfiguration;
use SFC\Staticfilecache\Cache\Rule\NoFakeFrontend;
use SFC\Staticfilecache\Cache\Rule\NoIntScripts;
use SFC\Staticfilecache\Cache\Rule\NoLongPathSegment;
Expand Down Expand Up @@ -38,7 +37,6 @@
use SFC\Staticfilecache\Service\ObjectFactoryService;
use TYPO3\CMS\Core\Cache\Backend\NullBackend;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Information\Typo3Version;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Utility\ExtensionUtility;

Expand All @@ -47,7 +45,6 @@ class Configuration extends StaticFileCacheObject
public const EXTENSION_KEY = 'staticfilecache';

protected ConfigurationService $configurationService;
protected Typo3Version $typo3version;

/**
* Configuration constructor.
Expand All @@ -58,7 +55,6 @@ class Configuration extends StaticFileCacheObject
public function __construct()
{
$this->configurationService = GeneralUtility::makeInstance(ConfigurationService::class);
$this->typo3version = GeneralUtility::makeInstance(Typo3Version::class);
}

/**
Expand Down Expand Up @@ -96,7 +92,6 @@ protected function registerRules(): self
'noWorkspacePreview' => NoWorkspacePreview::class,
'noUserOrGroupSet' => NoUserOrGroupSet::class,
'noIntScripts' => NoIntScripts::class,
'loginDeniedConfiguration' => LoginDeniedConfiguration::class,
'noNoCache' => NoNoCache::class,
'enable' => Enable::class,
'validPageInformation' => ValidPageInformation::class,
Expand Down

0 comments on commit 37fc64a

Please sign in to comment.