Review main Merged

61588[FEATURE] Provide core cache frontends via dependency injection

Markus Poerschke CR +2 V +2 Normal +144 −0 updated 09/11/19, 12:59

Commit message

Configure services for each service instance. The service names of the
cache frontends will follow this name pattern:
"cache.[NAME OF CONFIGURATION]".

E.g. the l10n cache frontend will be added as a service "cache.l10n".
(One exception has been made for the workspaces_cache, which is names
cache.workspaces)

Review

  • Code review CR +2 Done
    • Susi Moog +2
    • Benjamin Franzke +1
    • Oli Bartsch +1
    • Markus Poerschke +1
  • Verified V +2 Done
    • Susi Moog +2
    • Benjamin Franzke +1
    • TYPO3com +1 CI

Issues 1

Files 6

Review log 1723

  1. Markus Poerschke uploaded patch set 1 09/01/19, 18:51

  2. TYPO3com voted on patch set 1 V -1 09/01/19, 18:52 Completed build in 12s on Sun, 1 Sep, 06:52 PM Test Summary: No tests found Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35974

  3. Markus Poerschke uploaded patch set 2 09/01/19, 18:57

  4. TYPO3com voted on patch set 2 V -1 09/01/19, 19:08 Completed build in 10m 34s on Sun, 1 Sep, 07:08 PM Test Summary: 47256 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35975

  5. Markus Poerschke uploaded patch set 3 09/01/19, 19:12

  6. TYPO3com voted on patch set 3 V -1 09/01/19, 19:22 Completed build in 09m 49s on Sun, 1 Sep, 07:22 PM Test Summary: 47029 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35976

  7. TYPO3com voted on patch set 3 V +1 09/04/19, 11:58 Completed build in 16h 55m 36s on Wed, 4 Sep, 11:58 AM Test Summary: 47254 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-35976

  8. Benjamin Franzke commented on patch set 3 09/05/19, 07:38

    I do support cache.%name% container entries and agree that we should provide these for core caches – we actually already have that available for 'cache.core' and 'cache.assets' (see TYPO3\CMS\Core\Core\Bootstrap::init). But: As cacheConfigurations can not be (fully) known at DI compile time (it's altered in ext_localconf.php) we shouldn't try to add all cache entries automatically but rather add the known ones (core caches) to Services.yaml. Extensions that define an own cache should then also define a 'cache.my_cache' container entry. Do you agree? If so, would you like to update your patch or should I do?

    Services.php:25 Unresolved

    This will only pick up cacheConfigurations from LocationConfiguration/AdditionalConfiguration.php, not cacheConfigurations set in ext_localconf.php files. Therefore we should only add core caches (explicitly in the extensions Services.yaml).
  9. Benjamin Franzke voted on patch set 3 CR -1 09/05/19, 07:39

  10. Benjamin Franzke wrote 09/05/19, 07:39

    Topic set to di
  11. Benjamin Franzke commented on patch set 3 09/05/19, 07:47

    Btw, the alternative I mean are entries like the following in Services.yaml: cache.hash: class: TYPO3\CMS\Core\Cache\Frontend\FrontendInterface factory: ['@TYPO3\CMS\Core\Cache\CacheManager', 'getCache'] arguments: ['hash']
  12. Benjamin Franzke uploaded patch set 4 09/05/19, 08:09

  13. TYPO3com voted on patch set 4 V +1 09/05/19, 08:22 Completed build in 12m 08s on Thu, 5 Sep, 08:21 AM Test Summary: 47361 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36083

  14. Oli Bartsch commented on patch set 4 09/05/19, 21:04

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:20

    A full stop is missing here.

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:31

    What do you think about leaving that out since it should be clear that we are talking about TYPO3 here?

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:50

    Do we need that as we don't have a 2.) ... For me, it makes the sentence just harder to read.
  15. Frank Nägler voted on patch set 4 CR +1 09/06/19, 12:47

  16. Markus Poerschke uploaded patch set 5 09/08/19, 21:24

  17. Benjamin Franzke voted on patch set 5 V +1 CR +1 09/08/19, 21:26

  18. Markus Poerschke commented on patch set 5 CR +1 09/08/19, 21:30

    > Patch Set 3: > > (1 comment) > > I do support cache.%name% container entries and agree that we should provide these for core caches – we actually already have that available for 'cache.core' and 'cache.assets' (see TYPO3\CMS\Core\Core\Bootstrap::init). > > But: As cacheConfigurations can not be (fully) known at DI compile time (it's altered in ext_localconf.php) we shouldn't try to add all cache entries automatically but rather add the known ones (core caches) to Services.yaml. > Extensions that define an own cache should then also define a 'cache.my_cache' container entry. > > Do you agree? If so, would you like to update your patch or should I do? I double checked that. I did not see, that the ext_localconf.php files of the extensions are evaluated after the DI container is booted. I don’t like this behavior, because static configuration should be evaluated before building the container, but because it is possible to use classes, this is impossible without breaking changes. What do you think about to move the cache configuration to a YAML-file as well? Then these services could be generated automatically. (Where to discuss this, becauese this will exeed this changeset?) To me the changes look good and will help adopting the core to DI. I will adopt the pull request to the documentation on GitHub accordingly.

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:20 Reply

    Fixed.

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:31 Reply

    I removed it. You are right, that this should be clear.

    Feature-89054-ProvideCoreCacheFrontendsViaDependencyInjection.rst:50 Reply

    Removed.
  19. TYPO3com voted on patch set 5 V +1 09/08/19, 21:35 Completed build in 10m 56s on Sun, 8 Sep, 09:35 PM Test Summary: 47382 passed Find logs and detail information at https://bamboo.typo3.com/browse/CORE-GTC-36197

  20. Oli Bartsch voted on patch set 5 CR +1 09/09/19, 14:06

  21. Benjamin Franzke commented on patch set 5 09/09/19, 15:51

    > I double checked that. I did not see, that the ext_localconf.php files of the extensions are evaluated after the DI container is booted. See https://github.com/TYPO3/TYPO3.CMS/blob/v10.0.0/typo3/sysext/core/Classes/Core/Bootstrap.php#L133 The container is build (or loaded from cache) in Bootstrap.php line 133. ext_localconf.php is then loaded later, in line 142: https://github.com/TYPO3/TYPO3.CMS/blob/v10.0.0/typo3/sysext/core/Classes/Core/Bootstrap.php#L142 > I don’t like this behavior, because static configuration should be evaluated before building the container, but because it is possible to use classes, this is impossible without breaking changes. Yup, static configuration should be loaded before building the container (to be able to inject configuration values), but ext_localconf.php is dynamic and a mixture of configuration and service instantiation and wiring (think of registries or service instance configuration like done for the extbase signal slot dispatcher). ext_localconf's main design flaw is the mixture of initialization and configuration composition without assurance that all configuration is available before a configuration-dependent class is instantiated. You could call it badly designed ServiceProvider for our previous Singleton-Container GeneralUtility::makeInstance(). We've actually thought about loading ext_localconf.php before creating the container to be able to inject $GLOBALS['TYPO3_CONF_VARS'], and the POC patches contained ext_localconf.php-before-container-build for a very long time, see: https://review.typo3.org/c/Packages/TYPO3.CMS/+/58255/32/typo3/sysext/core/Classes/Core/Bootstrap.php#118 but in the end we noticed that due to ext_localconf.php's nature of instantiating registries (all over the place) all services that MAY be used in ext_localconf.php MUST NOT fully rely on dependency injection but would need to use nullable constructor injection with fallbacks to GeneralUtility::makeInstance() all over the place. That would (again) violate IoC. Therefore ext_localconf.php is now loaded afterwards. That allows for very clean service constructors. > What do you think about to move the cache configuration to a YAML-file as well? Then these services could be generated automatically. I personally like to add as much configuration as possible to the DI config, that means ServiceProviders (once they become a PSR) or in Services.yaml. Therefore I'd like to avoid another configuration file and would prefer service-level configuration to be done in DI config. But yes, symfony's Services.yaml is not that well suited for configuration assembling – that is something to discuss. > (Where to discuss this, becauese this will exeed this changeset?) Yup, good idea. We could discuss ideas like this (also the ext_localconf.php loading order) in the #initiative-psr11 channel on slack.
  22. Susi Moog voted on patch set 5 V +2 CR +2 09/11/19, 12:59

  23. Susi Moog merged patch set 6 09/11/19, 12:59