Review main Work in progress Orphaned

85833[TASK] Ensure resorting of package states in legacy mode

Stefan Bürk CR -2 V 0 Easy +4 −6 updated 04/12/25, 12:13

Commit message

The `extension:setup` command should be part of any
deployment strategy to ensure that all required db
tables and fields exist, which may have been added
meanwhile. That applies to composer and non-composer
based project setups.

The `ext_emconf.php` settings `depends` and `suggests`
influences the loading order of extensions in legacy
(non-composer) setups which may change in extension
and caches within the `PackageStates.php` file. Sadly,
in the current form there is no real conveniant way to
resort the information within the PackageStates.php
beside manually deleting it or changing the packages by
removing/adding packages.

This change modifies the `PackageManger` to ensure that
the `PackageStates.php` file is resorted and written in
all cases when `extension:setup` is used to ensure an
up-to-date state file.

Note that this does work already in composer mode setups
and thus only targets non-composer based setups and
TYPO3 Core monorepo setups.

Test this change

Run a command in your clone of the TYPO3 Core. Then try what the change does and vote on Verified in Gerrit. How to review a patch

Check out patch set 8
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/33/85833/8 && git checkout FETCH_HEAD
Cherry-pick onto main
git fetch https://review.typo3.org/Packages/TYPO3.CMS refs/changes/33/85833/8 && git cherry-pick FETCH_HEAD

Review

  • Code review CR -2 Blocked
    • Stefan Bürk -2
  • Verified V 0 Needs a vote

Issues 3

Files 1

Review log 1523

  1. Stefan Bürk uploaded patch set 1 08/30/24, 18:35

  2. Stefan Bürk updated the commit message in patch set 2 08/30/24, 18:43

  3. core-ci voted on patch set 1 V -1 08/30/24, 18:51 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64547

  4. Garvin Hicking updated the commit message in patch set 3 08/30/24, 18:57

  5. core-ci voted on patch set 2 V +1 08/30/24, 18:59 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64548

  6. core-ci voted on patch set 3 V -1 08/30/24, 19:15 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64551

  7. Stefan Bürk commented on patch set 3 CR -2 08/30/24, 20:18

    Need some investigation and clarification.
  8. Stefan Bürk updated the commit message in patch set 4 V -1 08/30/24, 20:18

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  9. core-ci voted on patch set 4 V -1 08/30/24, 20:36 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64555

  10. Stefan Bürk rebased onto patch set 5 V -1 09/10/24, 10:11

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  11. core-ci voted on patch set 5 V -1 09/10/24, 10:22 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65209

  12. core-ci voted on patch set 5 V +1 09/10/24, 10:35 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/65209

  13. Stefan Bürk updated the commit message in patch set 6 V +1 10/10/24, 17:33

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  14. Stefan Bürk rebased onto patch set 7 10/10/24, 17:33

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  15. Stefan Bürk commented on patch set 7 CR -2 10/10/24, 17:33

    Reply

    Done
  16. Stefan Bürk voted on patch set 7 CR 0 10/10/24, 17:33

  17. core-ci voted on patch set 7 V -1 10/10/24, 17:42 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67524

  18. core-ci voted on patch set 6 V -1 10/10/24, 17:44 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/67523

  19. Benjamin Franzke commented on patch set 7 CR -1 10/10/24, 19:02

    This will not only rewrite PackageStates.php during `extension:setup`, but whenever caches are flushed and PackageManager has to load packages from PackageStates.php (instead of the cache) – e.g. after `bin/typo3 cache:flush` That also means they are rewritten during `bin/typo3 cache:warmup`. This is not desirable. We must not change the file on disk without a need (remember this patch rewrites the file even when the contents do not change). BTW, on a read-only typo3conf this will even run into `PackageStatesFileNotWritableException`.
  20. Stefan Bürk commented on patch set 7 CR -1 10/10/24, 19:22

    Reply

    Give you change the settings in em_emconf.php of a extension in a legacy intall / monorepo e.g. adding/removing a dependency you have manually find and delete the package state as there is no way around to resort packages in that file, except uninstalling/installing a extension. Or after replacing a legacy core source symlink. IMO it is not documented to "delete" the file so it gets recreated during a legacy upgrade or similar and no other way to do that. That file is recreacted if missing, but not flushed/resorted with cache:flush. I'm open for a better solution except "knowing" to delete that file so it get recreated instead of resorted and document that as "best practice" for update. TBH not having a better solution at hand at the moment ... For example, we added missing depends to core ext_emconf.php recently. Legeacy install will not get this resorted UNTIL any install/uninstall extension action.
  21. Stefan Bürk voted on patch set 7 CR -2 10/10/24, 19:23

  22. Oliver Hader updated the commit message in patch set 8 CR -1 V -1 10/18/24, 13:58

    Copied Votes: * Code-Review-2 (copy condition: "changekind:NO_CHANGE OR **is:MIN**")
  23. Benni Mack marked it work in progress 04/12/25, 12:13