From b7596e8af1ec5deaacccc5a7005c7253557688b2 Mon Sep 17 00:00:00 2001 From: Benni Mack Date: Wed, 7 Dec 2022 13:29:46 +0100 Subject: [PATCH] [BUGFIX] Remove assetcollector URLs collections Since File-related events are in place, collecting used images and put them in cache is not necessary anymore, thus this part can be removed. Related: 21 --- Classes/Hook/FrontendHook.php | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/Classes/Hook/FrontendHook.php b/Classes/Hook/FrontendHook.php index befcabf..ca6b8b0 100755 --- a/Classes/Hook/FrontendHook.php +++ b/Classes/Hook/FrontendHook.php @@ -20,7 +20,6 @@ use Psr\Log\LoggerAwareTrait; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Cache\Exception\NoSuchCacheException; -use TYPO3\CMS\Core\Page\AssetCollector; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController; @@ -52,38 +51,11 @@ public function insertPageIncache(TypoScriptFrontendController $parentObject, $t // cache the page URL that was called $url = GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'); - $cache->set(md5($url), $url, $parentObject->getPageCacheTags()); + $cache->set(md5($url), $url, $parentObject->getPageCacheTags(), $timeOutTime); $this->logger->info( 'Marking page "%s" (uid %s) as cached.', [$url, $pageUid] ); - - $imageUrls = GeneralUtility::makeInstance(AssetCollector::class)->getMedia(); - $imageUrls = array_keys($imageUrls); - - foreach ($imageUrls as $imageUrl) { - // Only cache local files - $hasSchema = parse_url($imageUrl, PHP_URL_SCHEME); - if (!empty($hasSchema)) { - continue; - } - // If it's not from an extension, clear the cache - // Extension files are not changed, only during deployment, where we expect that all caches - // Are flushed - if (strpos($imageUrl, 'typo3conf/ext/') !== false) { - continue; - } - // processed images are not cached either - if (strpos($imageUrl, '/_processed_') !== false) { - continue; - } - $url = GeneralUtility::getIndpEnv('TYPO3_SITE_URL') . $imageUrl; - $cache->set(md5($url), $url, $parentObject->getPageCacheTags()); - $this->logger->info( - 'Marking image "%s" (on page %s) as cached.', - [$url, $pageUid] - ); - } } catch (NoSuchCacheException $e) { // No cache, nothing to do }