Review main Merged

93749[BUGFIX] Combine mtime and filesize for package cache identifier

Benjamin Kott CR +2 V +2 Normal +78 −5 updated 04/20/26, 18:09

Commit message

Installing an extension via the Extension Manager can dump a DI
container in which the just-activated extension's services are missing
entirely. Any code path that touches those services during activation
breaks the same way, regardless of whether it is a direct container
lookup, a tagged service, a registered event listener or an
instantiation from a TCA override.

The DI container cache identifier was derived from the PackageStates.php
mtime, which has 1-second resolution. When savePackageStates() rewrote
the file in the same wall-clock second that Bootstrap had previously
stat'd it, the identifier was identical to the one used for the
pre-activation container, and that stale cache.di entry was loaded for
the new package set. The just-activated extension's Services.yaml never
made it into the compiled container. Retries did not recover because
activatePackage() early-returns when the package is already active,
leaving the file untouched and the poisoned cache entry in place.

PackageStatesPackageCache::getIdentifier() now combines filemtime() and
filesize() via a single stat() call instead of relying on filemtime()
alone, eliminating the timestamp-resolution race at the cost of only
two extra metadata fields rather than a full file read.

Additionally the PHP stat cache is cleared, when invalidating the
identifier to make sure PHP does not use the cache on next stat() call

Review

  • Code review CR +2 Done
    • Stefan Bürk +2
    • Helmut Hummel +1
  • Verified V +2 Done
    • Stefan Bürk +2
    • Helmut Hummel +1
    • core-ci +1 CI

Issues 1

Files 2

Review log 2836

Show 911 earlier messages
  1. Benjamin Kott uploaded patch set 1 04/20/26, 11:33

  2. core-ci voted on patch set 1 V +1 04/20/26, 11:42 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100551

  3. Benjamin Kott rebased onto patch set 2 V +1 04/20/26, 12:07

  4. Christian Kuhn voted on patch set 2 CR +1 V +1 04/20/26, 12:15

  5. core-ci voted on patch set 2 V +1 04/20/26, 12:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100554

  6. Anja Leichsenring voted on patch set 2 CR +1 V +1 04/20/26, 12:27

  7. Christian Kuhn voted on patch set 2 CR 0 V 0 04/20/26, 12:40

  8. Christian Kuhn commented on patch set 2 04/20/26, 12:44

    This is bootstrap hot-path. For every request

    PackageStatesPackageCache.php:84

    This is bootstrap hot-path. For every request. The file is small and xxh3 is ultra fast, the impact is low. However, combination of mtime+filesize would shift the operation to file metadata only, which is more easy for kernel to cache. Should we consider this option? It should solve the race condition as well.
  9. Benjamin Kott commented on patch set 2 04/20/26, 13:05

    PackageStatesPackageCache.php:84 Reply

    i consider it unlikely that we for some reason manage to have it in the same second and manage to produce somehow the same filesize. so, this can also be an option. i am not sure about this, only pinpointed the problem and having a solution. we are using xxh3 in some other places too for similar checks.
  10. Benjamin Kott commented on patch set 2 04/20/26, 13:18

    PackageStatesPackageCache.php:84 Reply

    please go ahead and adjust if needed
  11. Christian Kuhn uploaded patch set 3 CR +1 V +1 04/20/26, 13:49

  1. Christian Kuhn commented on patch set 3 04/20/26, 13:50

    PackageStatesPackageCache.php:84 Reply

    Done
  2. Christian Kuhn voted on patch set 3 CR -1 04/20/26, 13:56

  3. core-ci voted on patch set 3 V +1 04/20/26, 13:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100569

  4. Christian Kuhn commented on patch set 3 04/20/26, 14:45

    will take care of a minor detail. stay tuned.
  5. Christian Kuhn uploaded patch set 4 CR -1 V +1 04/20/26, 16:04

  6. Christian Kuhn voted on patch set 4 CR +1 V +1 04/20/26, 16:04

  7. Helmut Hummel commented on patch set 4 CR -2 04/20/26, 16:14

    I think this is not necessary
  8. core-ci voted on patch set 4 V -1 04/20/26, 16:17 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100579

  9. Helmut Hummel commented on patch set 4 CR +1 V +1 04/20/26, 16:33

    oops sorry. thought this would still do a full content hash. using filesize stat is pretty smart, thanks Is there a reason this does not affect older branches as well?
  10. Helmut Hummel commented on patch set 4 CR 0 04/20/26, 16:36

    PackageStatesPackageCacheTest.php:66

    why this touch call?

    PackageStatesPackageCacheTest.php:67

    why clear the realpath cache as well?
  11. core-ci voted on patch set 4 V +1 04/20/26, 16:44 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100579

  12. Christian Kuhn commented on patch set 4 V 0 CR -1 04/20/26, 17:08

    will push.

    PackageStatesPackageCacheTest.php:66 Reply

    php caches stat() internally. the call ensures both assertions actually ensure on-disk state.

    PackageStatesPackageCacheTest.php:67 Reply

    yeah. that's not necessary.
  13. Christian Kuhn commented on patch set 4 04/20/26, 17:12

    PackageStatesPackageCacheTest.php:66 Reply

    so touch() takes care of internal php caches, and clearstatcache() is not needed. good catch. thx!
  14. Christian Kuhn commented on patch set 4 04/20/26, 17:12

    PackageStatesPackageCacheTest.php:67 Reply

    Done
  15. Christian Kuhn uploaded patch set 5 CR -1 V +1 04/20/26, 17:13

  16. Christian Kuhn commented on patch set 5 04/20/26, 17:15

    Reply

    yes. v13 backport is a good idea.
  17. Christian Kuhn updated the commit message in patch set 6 04/20/26, 17:15

  18. Christian Kuhn voted on patch set 6 CR +1 V +1 04/20/26, 17:15

  19. core-ci voted on patch set 5 V -1 04/20/26, 17:18 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100589

  20. core-ci voted on patch set 6 V -1 04/20/26, 17:24 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100590

  21. Helmut Hummel uploaded patch set 7 CR +1 V +1 04/20/26, 17:26

  22. Helmut Hummel voted on patch set 7 CR +1 V +1 04/20/26, 17:26

  23. core-ci voted on patch set 7 V +1 04/20/26, 17:39 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/100591

  24. Stefan Bürk voted on patch set 7 CR +2 V +2 04/20/26, 18:09

  25. Stefan Bürk merged patch set 8 04/20/26, 18:09