diff --git a/typo3/sysext/core/Classes/DependencyInjection/Cache/ContainerBackend.php b/typo3/sysext/core/Classes/DependencyInjection/Cache/ContainerBackend.php index b0feb97d2af102cca28b758b184342f34ceb14dc..0f5b1ea762e0d47eb02efbe563c37646fe29d3ca 100644 --- a/typo3/sysext/core/Classes/DependencyInjection/Cache/ContainerBackend.php +++ b/typo3/sysext/core/Classes/DependencyInjection/Cache/ContainerBackend.php @@ -35,4 +35,9 @@ class ContainerBackend extends SimpleFileBackend parent::flush(); parent::set($entryIdentifier, $data, $tags, $lifetime); } + + public function forceFlush(): void + { + parent::flush(); + } } diff --git a/typo3/sysext/install/Classes/Service/ClearCacheService.php b/typo3/sysext/install/Classes/Service/ClearCacheService.php index 9eba056caadc67c67b80a9a16669c8ce41eebd3c..a306b63e30a565099f1683d8ef387bfcb1d61fac 100644 --- a/typo3/sysext/install/Classes/Service/ClearCacheService.php +++ b/typo3/sysext/install/Classes/Service/ClearCacheService.php @@ -16,7 +16,9 @@ namespace TYPO3\CMS\Install\Service; use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Cache\Frontend\FrontendInterface; use TYPO3\CMS\Core\Database\ConnectionPool; +use TYPO3\CMS\Core\DependencyInjection\Cache\ContainerBackend; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -34,9 +36,17 @@ class ClearCacheService */ private $lateBootService; - public function __construct(LateBootService $lateBootService) - { + /** + * @var FrontendInterface + */ + private $dependencyInjectionCache; + + public function __construct( + LateBootService $lateBootService, + FrontendInterface $dependencyInjectionCache + ) { $this->lateBootService = $lateBootService; + $this->dependencyInjectionCache = $dependencyInjectionCache; } /** @@ -44,7 +54,7 @@ class ClearCacheService * Goal is to reliably get rid of cache entries, even if some broken * extension is loaded that would kill the backend 'clear cache' action. * - * Therefor this method "knows" implementation details of the cache + * Therefore this method "knows" implementation details of the cache * framework and uses them to clear all file based cache (typo3temp/Cache) * and database caches (tables prefixed with cf_) manually. * @@ -66,9 +76,12 @@ class ClearCacheService $this->flushCaches($baseCaches); // Remove DI container cache (this might be removed in preference of functionality to rebuild this cache) - // We need to remove using the remove method because the DI cache backend disables the flush method - $container = $this->lateBootService->getContainer(); - $container->get('cache.di')->remove(get_class($container)); + if ($this->dependencyInjectionCache->getBackend() instanceof ContainerBackend) { + /** @var ContainerBackend $diCacheBackend */ + $diCacheBackend = $this->dependencyInjectionCache->getBackend(); + // We need to remove using the forceFlush method because the DI cache backend disables the flush method + $diCacheBackend->forceFlush(); + } // From this point on, the code may fatal, if some broken extension is loaded. $this->lateBootService->loadExtLocalconfDatabaseAndExtTables(); diff --git a/typo3/sysext/install/Classes/ServiceProvider.php b/typo3/sysext/install/Classes/ServiceProvider.php index 5226c5ffbf36abf738a4c0bca629451a80f27b6d..714c5671e7364225ee8d821956eb52fcce166589 100644 --- a/typo3/sysext/install/Classes/ServiceProvider.php +++ b/typo3/sysext/install/Classes/ServiceProvider.php @@ -107,7 +107,8 @@ class ServiceProvider extends AbstractServiceProvider public static function getClearCacheService(ContainerInterface $container): Service\ClearCacheService { return new Service\ClearCacheService( - $container->get(Service\LateBootService::class) + $container->get(Service\LateBootService::class), + $container->get('cache.di') ); }