Review main Merged

70810[TASK] Unify core cache identifiers

Helmut Hummel CR +2 V +2 Hard +214 −137 updated 10/02/21, 14:40

Commit message

Core cache is used in many places throughout the core,
mostly to cache resources gathered from installed
extensions. In every single place the cache identifier
for these caches is constructed in a similar, but
not identical way.

This change aims to unify the cache identifiers and
introduce a (private) API to generate a cache identifier
same way for all core caches.

As a "side effect" all identifier suffixes are now
identical and can be recognized to belong together.

Review

  • Code review CR +2 Done
    • Benjamin Franzke +2
    • Nikita Hovratov +1
  • Verified V +2 Done
    • Benjamin Franzke +2
    • Nikita Hovratov +1
    • core-ci +1 CI

Issues 1

Files 37

Show 17 more files

Review log 3749

Show 1624 earlier messages
  1. Helmut Hummel uploaded patch set 1 08/28/21, 20:24

  2. Helmut Hummel uploaded patch set 2 08/28/21, 20:25

  3. core-ci voted on patch set 1 V -1 08/28/21, 20:29 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15788

  4. core-ci voted on patch set 2 V -1 08/28/21, 20:38 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15789

  5. Benni Mack rebased onto patch set 3 08/30/21, 06:15

  6. core-ci voted on patch set 3 V -1 08/30/21, 06:19 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/15837

  7. Benjamin Franzke commented on patch set 3 08/30/21, 06:23

    ExtensionManagementUtility.php:1487

    As already mentioned on slack: I very much like this change in general, but would like to see this method to be part of a new service, something like "CacheHashService" or so. Reason: ExtensionManagementUtility already has a static dependency and this dependnecy then becomes (again) implicit to all users of this method. Therefore I'd prefer a service that can be injected by the users of this method.
  8. Benni Mack commented on patch set 3 09/02/21, 09:47

    ExtensionManagementUtility.php:1487 Reply

    How about putting this into PackageManager?
  9. Benjamin Franzke commented on patch set 3 09/02/21, 11:35

    ExtensionManagementUtility.php:1487 Reply

    Well, we rather not want to inject PackageManager everywhere, just for the cache identifier usage, therefore we thought it would be better to use a specific service instead of a "god" service. We ended up with naming it "PackageDependentCacheIdentifier->create()". Helmut wanted to continue with that, maybe he got sidetracked.
  10. Helmut Hummel commented on patch set 3 09/29/21, 14:32

    ExtensionManagementUtility.php:1487 Reply

    yeah. will pick it up now
  11. Helmut Hummel uploaded patch set 4 09/29/21, 15:52

  12. core-ci voted on patch set 4 V -1 09/29/21, 16:08 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17317

  13. Helmut Hummel uploaded patch set 5 09/29/21, 19:20

  14. Helmut Hummel commented on patch set 5 09/29/21, 19:21

    ExtensionManagementUtility.php:1487 Reply

    Done
  15. core-ci voted on patch set 5 V -1 09/29/21, 19:23 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17320

  16. Helmut Hummel uploaded patch set 6 09/29/21, 19:52

  17. core-ci voted on patch set 6 V -1 09/29/21, 20:12 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17321

  18. Benni Mack commented on patch set 6 09/30/21, 09:47

    ReflectionService.php:81

    should we use GeneralUtility::getContainer()->get() here?
  19. Benjamin Franzke commented on patch set 6 09/30/21, 12:41

    ReflectionService.php:81 Reply

    We should inject PackageDependentCacheIdentifier. Talked with helmut via slack yesterday and we agreed to fix some extbase DI things first in the following preparatoy patch: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71376
  20. Helmut Hummel uploaded patch set 7 10/01/21, 10:26

  21. Helmut Hummel commented on patch set 7 10/01/21, 10:28

    ReflectionService.php:81 Reply

    Ack
  22. core-ci voted on patch set 7 V -1 10/01/21, 10:47 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17401

  23. Benjamin Franzke uploaded patch set 8 10/01/21, 14:03

  24. core-ci voted on patch set 8 V -1 10/01/21, 14:08 Core CI is not happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17439

  1. Benjamin Franzke uploaded patch set 9 10/01/21, 15:20

  2. Xavier Perseguers commented on patch set 9 10/01/21, 15:33

    PackageDependentCacheIdentifier.php:38

    Nitpicking but would have preferred reading __toString()
  3. core-ci voted on patch set 9 V +1 10/01/21, 15:44 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17449

  4. Benjamin Franzke commented on patch set 9 10/01/21, 17:19

    PackageDependentCacheIdentifier.php:38 Reply

    Wouldn't look very nice if we then (still) need to call it explicitly in symfony expressions with `__toString()`. Therefore I personally think toString() is fine for this case. Do you agree?
  5. Helmut Hummel commented on patch set 9 10/01/21, 21:52

    PackageDependentCacheIdentifier.php:38 Reply

    I also always learned to appreciate explicit code over implicit code.
  6. Xavier Perseguers commented on patch set 9 10/02/21, 06:31

    PackageDependentCacheIdentifier.php:38 Reply

    Fine with me, I just prefer sticking to the programming language paradigms while still being explicit. There's an official way of converting an object to a string which is casting thus using `(string)` as prefix and you can tell PHP how to do the casting by overriding the method `__toString()`. I find it much better than inventing a `toString()` method which basically does the same but doesn't allow either casting or implicit casting. Again, it's possibly just a matter of taste, this is why I wrote that's a bit nitpicking but I still consider that I prefer sticking to the language whenever I can instead of inventing something looking similar.
  7. Xavier Perseguers commented on patch set 9 10/02/21, 06:33

    PackageDependentCacheIdentifier.php:38 Reply

    and btw, we use an explicit casting of some object to (string) a lot already in Core, so it's not like it would be coming from nowhere :)
  8. Benjamin Franzke commented on patch set 9 10/02/21, 06:37

    PackageDependentCacheIdentifier.php:38 Reply

    Still, please consider the usage in symfony expressions, __toString() would be ugly there. I think it's good in this case. Would agree otherwise (for consistency).
  9. Xavier Perseguers commented on patch set 9 10/02/21, 06:39

    PackageDependentCacheIdentifier.php:38 Reply

    OK, fine then, it's then a severe limitation of Symphony not smart enough to take advantage of casting and this "feature" in most programming languages.
  10. Benjamin Franzke commented on patch set 9 10/02/21, 07:40

    PackageDependentCacheIdentifier.php:38 Reply

    Sorry, i was wrong. we could use __toString() as php will auto cast due to the `string` type declaration. @Helmut: I'd be fine either way.. Remove `.toString()` would actually look better in the expressions.
  11. Nikita Hovratov uploaded patch set 10 10/02/21, 08:03

  12. Helmut Hummel commented on patch set 10 10/02/21, 08:10

    PackageDependentCacheIdentifier.php:38 Reply

    As I said, I think code benefits from being explicit. If I sxplicity call toString, I immediately know and understand than this is an object that can be converted to a string, while when I just string concatenate two variables, I must know that they are indeed castable or strings. However if this REALLY is the only thing to complain and a blocker for this change to be merged, then I'll accept implicitly here.
  13. Nikita Hovratov uploaded patch set 11 10/02/21, 08:16

  14. core-ci voted on patch set 10 V +1 10/02/21, 08:17 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17474

  15. Benjamin Franzke commented on patch set 11 V +1 CR +1 10/02/21, 08:19

    PackageDependentCacheIdentifier.php:38 Reply

    Ok, have to correct myself: a) auto casting wont work with declare(strict_types=1; b) symfony DI/expressions not warn about that in expressions This patch is good as is. Thanks for discussion anyway.
  16. Nikita Hovratov voted on patch set 11 V +1 CR +1 10/02/21, 08:28

  17. core-ci voted on patch set 11 V +1 10/02/21, 08:31 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17475

  18. Nikita Hovratov commented on patch set 11 CR -1 10/02/21, 08:33

    One missed place found in: typo3/sysext/core/Classes/Imaging/IconProvider/FontawesomeIconProvider->getCacheIdentifier
  19. Nikita Hovratov uploaded patch set 12 10/02/21, 08:59

  20. Benjamin Franzke voted on patch set 12 V +1 CR +1 10/02/21, 09:10

  21. Nikita Hovratov voted on patch set 12 V +1 CR +1 10/02/21, 09:18

  22. core-ci voted on patch set 12 V +1 10/02/21, 09:22 Core CI is happy: https://gitlab.typo3.org/typo3/CI/cms/-/pipelines/17479

  23. Benjamin Franzke voted on patch set 12 V +2 CR +2 10/02/21, 09:28

  24. Benjamin Franzke merged patch set 13 10/02/21, 09:28

  25. Helmut Hummel commented on patch set 13 10/02/21, 14:40

    Reply

    Actually, I left this out intentionally, because this cache does NOT depend on loaded packages