Project

General

Profile

Actions

Bug #90962

open

Cache and Dependency Injection in Upgrade module

Added by Chris Müller over 4 years ago. Updated over 4 years ago.

Status:
New
Priority:
Should have
Assignee:
-
Category:
-
Target version:
-
Start date:
2020-04-06
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
10
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

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

Exception thrown from Check TCA

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

upgrade_check_tca.png (127 KB) upgrade_check_tca.png Exception thrown from "Check TCA" Chris Müller, 2020-04-06 15:58

Related issues 1 (0 open1 closed)

Related to TYPO3 Core - Bug #91516: Install-Tool -> Analyze Database Structure is broken / fails if cache tables dosen't existClosed2020-05-28

Actions
Actions #1

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.

Actions #2

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.

Actions #3

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
Actions

Also available in: Atom PDF