diff --git a/Classes/Generator/BrotliGenerator.php b/Classes/Generator/BrotliGenerator.php index ba104be8c4c..81f892cd3bb 100644 --- a/Classes/Generator/BrotliGenerator.php +++ b/Classes/Generator/BrotliGenerator.php @@ -5,13 +5,17 @@ namespace SFC\Staticfilecache\Generator; use Psr\Http\Message\ResponseInterface; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use SFC\Staticfilecache\Event\GeneratorCreate; use SFC\Staticfilecache\Event\GeneratorRemove; use SFC\Staticfilecache\Service\RemoveService; use TYPO3\CMS\Core\Utility\GeneralUtility; -class BrotliGenerator extends AbstractGenerator +class BrotliGenerator extends AbstractGenerator implements LoggerAwareInterface { + use LoggerAwareTrait; + public function generate(GeneratorCreate $generatorCreateEvent): void { if (!$this->checkAvailable()) { diff --git a/Classes/Middleware/GenerateMiddleware.php b/Classes/Middleware/GenerateMiddleware.php index 76699d86e00..e3227437489 100644 --- a/Classes/Middleware/GenerateMiddleware.php +++ b/Classes/Middleware/GenerateMiddleware.php @@ -16,6 +16,7 @@ use SFC\Staticfilecache\Service\ConfigurationService; use SFC\Staticfilecache\Service\CookieService; use SFC\Staticfilecache\Service\DateTimeService; +use TYPO3\CMS\Core\Information\Typo3Version; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; use TYPO3\CMS\Frontend\Event\AfterCachedPageIsPersistedEvent; @@ -24,10 +25,12 @@ class GenerateMiddleware implements MiddlewareInterface { protected ?UriFrontend $cache = null; + protected ServerRequestInterface $request; public function __construct( - protected EventDispatcherInterface $eventDispatcher, - protected CookieService $cookieService + readonly protected EventDispatcherInterface $eventDispatcher, + readonly protected CookieService $cookieService, + readonly protected Typo3Version $typo3Version ) {} /** @@ -39,6 +42,7 @@ public function __construct( */ public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface { + $this->request = $request; $response = $handler->handle($request); if (!$response->hasHeader('X-SFC-Cachable')) { @@ -90,9 +94,14 @@ protected function calculateLifetime(TypoScriptFrontendController $tsfe): int // @todo migrate for v13 to Events // Check ModifyCacheLifetimeForPageEvent & AfterCachedPageIsPersistedEvent - // @phpstan-ignore-next-line - // @todo check this Line!!! - $timeOutTime = $tsfe->get_cache_timeout(); + if ($this->typo3Version->getMajorVersion() >= 13) { + /* @phpstan-ignore-next-line */ + $timeOutTime = $tsfe->get_cache_timeout($this->request); + } else { + /* @phpstan-ignore-next-line */ + $timeOutTime = $tsfe->get_cache_timeout(); + } + // If page has a endtime before the current timeOutTime, use it instead: if ($tsfe->page['endtime'] > 0 && ($tsfe->page['endtime'] - $GLOBALS['EXEC_TIME']) < $timeOutTime) { diff --git a/Classes/Service/ClientService.php b/Classes/Service/ClientService.php index 9c545f6c7c6..30a45e97a69 100644 --- a/Classes/Service/ClientService.php +++ b/Classes/Service/ClientService.php @@ -9,12 +9,16 @@ use GuzzleHttp\Cookie\SetCookie; use GuzzleHttp\HandlerStack; use Psr\EventDispatcher\EventDispatcherInterface; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use SFC\Staticfilecache\Event\BuildClientEvent; use TYPO3\CMS\Core\Utility\ArrayUtility; use TYPO3\CMS\Core\Utility\GeneralUtility; -class ClientService extends AbstractService +class ClientService extends AbstractService implements LoggerAwareInterface { + use LoggerAwareTrait; + protected const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0'; public function __construct(protected EventDispatcherInterface $eventDispatcher) {} diff --git a/Classes/Service/CookieService.php b/Classes/Service/CookieService.php index f6cfab7b2c9..1e66928a2e9 100644 --- a/Classes/Service/CookieService.php +++ b/Classes/Service/CookieService.php @@ -4,14 +4,18 @@ namespace SFC\Staticfilecache\Service; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use SFC\Staticfilecache\Service\DateTimeService; use TYPO3\CMS\Core\Utility\GeneralUtility; /** * Handle cookie related stuff. */ -class CookieService extends AbstractService +class CookieService extends AbstractService implements LoggerAwareInterface { + use LoggerAwareTrait; + public const SESSION_LIFETIME = 0; /** diff --git a/Classes/Service/QueueService.php b/Classes/Service/QueueService.php index 190a9c46d7f..8173fdd6e04 100644 --- a/Classes/Service/QueueService.php +++ b/Classes/Service/QueueService.php @@ -4,6 +4,8 @@ namespace SFC\Staticfilecache\Service; +use Psr\Log\LoggerAwareInterface; +use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; use SFC\Staticfilecache\Command\BoostQueueCommand; use SFC\Staticfilecache\Domain\Repository\QueueRepository; @@ -13,8 +15,10 @@ * * @see BoostQueueCommand */ -class QueueService extends AbstractService +class QueueService extends AbstractService implements LoggerAwareInterface { + use LoggerAwareTrait; + public const PRIORITY_HIGH = 2000; public const PRIORITY_MEDIUM = 1000; public const PRIORITY_LOW = 0;