From 35157fbafaf3d898f2c2ec1e8eeb3ca760cd69d5 Mon Sep 17 00:00:00 2001 From: Sascha Nowak Date: Fri, 4 Aug 2023 14:27:51 +0200 Subject: [PATCH] [BUGFIX] Flush DI cache with clear all caches on development context Resolves: #101577 Releases: 12.4, main Change-Id: If2093146c7066e37881e43ff96c527f5e1efd482 Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/80356 Tested-by: Benjamin Franzke Reviewed-by: Benjamin Franzke Tested-by: core-ci --- typo3/sysext/core/Classes/DataHandling/DataHandler.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/typo3/sysext/core/Classes/DataHandling/DataHandler.php b/typo3/sysext/core/Classes/DataHandling/DataHandler.php index fe0f4312e081..f5bc965cb40b 100644 --- a/typo3/sysext/core/Classes/DataHandling/DataHandler.php +++ b/typo3/sysext/core/Classes/DataHandling/DataHandler.php @@ -19,6 +19,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform as PostgreSQLPlatform; use Doctrine\DBAL\Types\IntegerType; use Doctrine\DBAL\Types\JsonType; +use Psr\Container\ContainerInterface; use Psr\EventDispatcher\EventDispatcherInterface; use Psr\Log\LoggerAwareInterface; use Psr\Log\LoggerAwareTrait; @@ -35,6 +36,7 @@ use TYPO3\CMS\Core\Configuration\FlexForm\Exception\InvalidPointerFieldValueException; use TYPO3\CMS\Core\Configuration\FlexForm\FlexFormTools; use TYPO3\CMS\Core\Configuration\Richtext; +use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Crypto\PasswordHashing\InvalidPasswordHashException; use TYPO3\CMS\Core\Crypto\PasswordHashing\PasswordHashFactory; use TYPO3\CMS\Core\Crypto\Random; @@ -9361,6 +9363,12 @@ public function clear_cacheCmd($cacheCmd) // Delete Opcode Cache GeneralUtility::makeInstance(OpcodeCacheService::class)->clearAllActive(); + + // Delete DI Cache only on development context + if (Environment::getContext()->isDevelopment()) { + $container = GeneralUtility::makeInstance(ContainerInterface::class); + $container->get('cache.di')->getBackend()->forceFlush(); + } } break; }