Bug #90962
openCache and Dependency Injection in Upgrade module
0%
Description
In my schema extension I injected a frontend cache with DI into a class.
The cache is defined in the ext_localconf.php:
$coreCacheIdentifier = 'tx_' . $extensionKey . '_core'; if (!is_array($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier] = []; } if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['frontend'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['frontend'] = \TYPO3\CMS\Core\Cache\Frontend\PhpFrontend::class; } if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['backend'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['backend'] = \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend::class; } if (!isset($GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['options'])) { $GLOBALS['TYPO3_CONF_VARS']['SYS']['caching']['cacheConfigurations'][$coreCacheIdentifier]['options']['defaultLifetime'] = 0; }
and listed correctly in the Configuration module.
Definition in Services.yaml:
services: cache.tx_schema_core: class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] arguments: ['tx_schema_core'] Brotkrueml\Schema\Registry\TypeRegistry: arguments: $cache: '@cache.tx_schema_core' $packageManager: '@TYPO3\CMS\Core\Package\PackageManager'
In the TypeRegistry class itself, the the constructor looks like:
public function __construct(FrontendInterface $cache = null, PackageManager $packageManager = null)
The injection works for most cases in frontend and backend. However, executing two routines in the Upgrade module fail:
- Check TCA in ext_tables.php
- Check TCA Migrations
But: When I define the cache in the AdditionalConfiguration.php instead of localconf.php it works. Also when deactivating DI in Services.yaml
The behaviour can be reproduced with the schema extension (commit af18687d from April 5th):
https://github.com/brotkrueml/schema
Files
Updated by Nikita Hovratov over 4 years ago
Hi, so I'm not sure if tca should be dependent of the extensions ext_localconf.php. At least they are not loaded in the checks. Maybe someone knows better, but as a workaround you could use the AfterTcaCompilationEvent
and fill the items there. I tried it with your extension and it worked fine.
Updated by Markus Klein over 4 years ago
We had the same issue. The Install Tool does not load the ext_localconf files for clearing the cache.
You need to define your cache configuration either in LocalConfiguration or AdditionalConfiguration.
Updated by Markus Klein over 4 years ago
- Related to Bug #91516: Install-Tool -> Analyze Database Structure is broken / fails if cache tables dosen't exist added