diff --git a/typo3/sysext/install/Classes/Controller/AbstractController.php b/typo3/sysext/install/Classes/Controller/AbstractController.php index d832dbdca8a47a6b7f1c29b64660d315f7c4ec26..fe63b074bec92fe47caa2b38796f363235706481 100644 --- a/typo3/sysext/install/Classes/Controller/AbstractController.php +++ b/typo3/sysext/install/Classes/Controller/AbstractController.php @@ -16,6 +16,7 @@ namespace TYPO3\CMS\Install\Controller; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Install\Service\EnableFileService; +use TYPO3\CMS\Core\Cache\Backend\NullBackend; /** * Controller abstract for shared parts of Tool, Step and Ajax controller @@ -401,40 +402,34 @@ class AbstractController { /** * Require dbal ext_localconf if extension is loaded - * Required extbase + fluid ext_localconf - * Set caching to null, we do not want dbal, fluid or extbase to cache anything + * Required extbase ext_localconf + * Set caching to NullBackend, install tool must not cache anything * * @return void */ protected function loadBaseExtensions() { if ($this->isDbalEnabled()) { require(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('dbal') . 'ext_localconf.php'); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['dbal']['options'] = array(); } + // @todo: Find out if this could be left out require(\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath('extbase') . 'ext_localconf.php'); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap']['options'] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_object']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_object']['options'] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection']['options'] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns']['options'] = array(); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template']['backend'] - = \TYPO3\CMS\Core\Cache\Backend\NullBackend::class; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['fluid_template']['options'] = array(); + $cacheConfigurations = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']; + + $cacheConfigurationsWithCachesSetToNullBackend = array(); + foreach ($cacheConfigurations as $cacheName => $cacheConfiguration) { + // cache_core and cache_classes are handled in bootstrap already + if (is_array($cacheConfiguration) && $cacheName !== 'cache_core' && $cacheName !== 'cache_classes') { + $cacheConfiguration['backend'] = NullBackend::class; + $cacheConfiguration['options'] = array(); + } + $cacheConfigurationsWithCachesSetToNullBackend[$cacheName] = $cacheConfiguration; + } /** @var $cacheManager \TYPO3\CMS\Core\Cache\CacheManager */ $cacheManager = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); - $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']); + $cacheManager->setCacheConfigurations($cacheConfigurationsWithCachesSetToNullBackend); } /** diff --git a/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php b/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php index 583b2a8980d54401d9c397022c8e71786fd92af3..687d20cfbe13e380ef749c037cba2038434a5f92 100644 --- a/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php +++ b/typo3/sysext/install/Classes/Service/CachingFrameworkDatabaseSchemaService.php @@ -14,6 +14,9 @@ namespace TYPO3\CMS\Install\Service; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Cache\CacheManager; +use TYPO3\CMS\Core\Cache\CacheFactory; + /** * This service provides the sql schema for the caching framework */ @@ -24,44 +27,24 @@ class CachingFrameworkDatabaseSchemaService { * * This method needs ext_localconf and ext_tables loaded! * - * This is a hack, but there was no smarter solution with current cache configuration setup: - * ToolController sets the extbase caches to NullBackend to ensure the install tool does not - * cache anything. The CacheManager gets the required SQL from database backends only, so we need to - * temporarily 'fake' the standard db backends for extbase caches so they are respected. - * - * Additionally, the extbase_object cache is already in use and instantiated, and the CacheManager singleton - * does not allow overriding this definition. The only option at the moment is to 'fake' another cache with - * a different name, and then substitute this name in the sql content with the real one. - * - * @TODO: http://forge.typo3.org/issues/54498 - * @TODO: It might be possible to reduce this ugly construct by circumventing the 'singleton' of CacheManager by using 'new' - * * @return string Cache framework SQL */ public function getCachingFrameworkRequiredDatabaseSchema() { - $cacheConfigurationBackup = $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']; - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_datamapfactory_datamap'] = array( - 'groups' => array('system') - ); - $extbaseObjectFakeName = uniqid('extbase_object'); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$extbaseObjectFakeName] = array( - 'groups' => array('system') - ); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_reflection'] = array( - 'groups' => array('system') - ); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']['extbase_typo3dbbackend_tablecolumns'] = array( - 'groups' => array('system') - ); - /** @var \TYPO3\CMS\Core\Cache\CacheManager $cacheManager */ - $cacheManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Core\Cache\CacheManager::class); - $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']); - $cacheSqlString = \TYPO3\CMS\Core\Cache\Cache::getDatabaseTableDefinitions(); - $sqlString = str_replace($extbaseObjectFakeName, 'extbase_object', $cacheSqlString); - $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] = $cacheConfigurationBackup; + // Use new to circumvent the singleton pattern of CacheManager + $cacheManager = new CacheManager; $cacheManager->setCacheConfigurations($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations']); + // Cache manager needs cache factory. cache factory injects itself to manager in __construct() + new CacheFactory('production', $cacheManager); + + $tableDefinitions = ''; + foreach ($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'] as $cacheName => $_) { + $backend = $cacheManager->getCache($cacheName)->getBackend(); + if (method_exists($backend, 'getTableDefinitions')) { + $tableDefinitions .= LF . $backend->getTableDefinitions(); + } + } - return $sqlString; + return $tableDefinitions; } /**