Review main Merged

85750[BUGFIX] Ensure proper loading order of EXT:seo and EXT:dashboard

Garvin Hicking CR +2 V +2 Easy +5 −3 updated 09/02/24, 14:07

Commit message

With #103034 EXT:styleguide received a dependency on EXT:seo.

This could lead to a situation for classic installations
(non-composer mode) where via `PackageStates.php` the
loading order was changed in a way that loaded
EXT:dashboard before EXT:seo.

This would lead to widgets defined in EXT:seo not
getting displayed in the dashboard, because the registration
would be performed too late.

The easy fix for this is to adjust the file `ext_emconf.php`
of EXT:seo to provide a 'suggest' key for EXT:dashboard.
The expected PackageStates default in the functional tests
are adapted to match that proper order.

In case EXT:seo is enabled, this 'suggest' entry ensures
that EXT:dashboard is loaded before EXT:seo, so that
everything else falls into place.

Please note that for composer installations this suggestion
was already provided.

For classic installations, [1] states:

    For non-Composer installation ("Classic Mode") the
    `ext_emconf.php` file is the source of truth for required
    dependencies and the loading order of active extensions.

NOTE: To fix a possible ordering problem in existing
installations, rebuilding `PackageStates.php` is needed.
This can be done by enabling and disabling EXT:dashboard
for example, through the Extension Manager.

[1] https://docs.typo3.org/c/typo3/cms-core/main/en-us/Changelog/11.4/Important-95647-ComposerInstallationsAndExtensionUsage.html

Review

  • Code review CR +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Stefan Bürk +1
    • Christian Kuhn +1
  • Verified V +2 Done
    • Garvin Hicking +2
    • Benjamin Franzke +1
    • Stefan Bürk +1
    • core-ci +1 CI

Issues 3

Files 2

Review log 1721

  1. Garvin Hicking uploaded patch set 1 08/23/24, 16:12

  2. core-ci voted on patch set 1 V +1 08/23/24, 16:17 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64090

  3. Philipp Kuhlmay commented on patch set 1 08/23/24, 16:54

    I cannot say much about the code, if it is the correct way, but at least this implementation works for me.

    SeoCompilerPass.php:37

    Wouldn't it be better to name this something like $pagesWithoutMetaDescriptionDefinition? I know this is long but what, if I want to add more widgets there? Then I would use the $definition variable again, to create a new definition? It would be easier to read if there will be another definition like "$pagesWithoutTitleDefinition" when I want to add the according widget, right?
  4. Garvin Hicking commented on patch set 1 08/23/24, 17:31

    SeoCompilerPass.php:37 Reply

    sure, feel free to adapt :)
  5. Garvin Hicking commented on patch set 1 08/23/24, 17:33

    If we pursue this, we should create probably a functional test with the extensions loaded and seeing that the registry holds the widgets of all extensions.
  6. Stefan Bürk commented on patch set 1 08/23/24, 19:13

    If I add `dashboard` as suggestion to the `seo` extension `ext_emconf.php` and uninstall/install dashboard dashboard extension gets added before the seo extension in the non-composer PackageStates file. From a quick peak into the package / package manager code thingy the composer.json suggestion should be enough (even for legacy/monorepo mode). I'd suggest to investigate in that area first regarding following questions: * is composer.json suggest enough ? * do we really need to duplicate the suggest(ion) in the ext_emconf.php ? * does this implies more documentation/agresive statement in documentation ? * can `extension:setup` be used to enforce reordering of current package information beside that, in monorepo this may be an issue if added and core contributors does not enable/disable extension. IMO in non-composer installation this should be updated on core updates anyway and then when extension get active/inactive. The current solution would delay it but no longer respecting "loading" order. Maybe it is possible to have something in service.yaml do do a condition like that (is a service already registered) or can be provided so we can do it aka `extension is loaded thingy). But that would be a new feature anyway. Instead of using a "compiler pass" to move that around I would fix the "root cause" and not mitigate the symptom.
  7. Garvin Hicking uploaded patch set 2 V +1 08/28/24, 09:10

  8. Garvin Hicking updated the commit message in patch set 3 08/28/24, 09:15

  9. Garvin Hicking commented on patch set 2 08/28/24, 09:16

    Reply

    You are great, Stefan, thank you. I learned about the importance of 'suggest' thanks to you. I've adjusted the patch and documented it. ext_emconf.php still is needed for this; all the code is still aligned for that file in non-composer mode. That would be beyond the scope of fixing this situation of missing widget registrations, and is documented that extensions providing classic/legacy support need to do that.
    Please note that I propose backporting this to v12, to align ext_emconf with composer.json and prevent possible scenarious in existing installations. I am unsure if we should create an "Important.rst" for this edge case, to make people aware they need to regeneration PackageStates.php when performing a minor upgrade and hitting this bug.
  10. Garvin Hicking commented on patch set 3 08/28/24, 09:17

    Reply

    No longer needed by removing compiler passes.

    SeoCompilerPass.php:37 Reply

    Resolved, approach no longer applies.
  11. core-ci voted on patch set 2 V -1 08/28/24, 09:20 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64393

  12. core-ci voted on patch set 3 V -1 08/28/24, 09:25 Core CI is not happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64394

  13. Garvin Hicking uploaded patch set 4 V -1 08/28/24, 12:01

  14. core-ci voted on patch set 4 V +1 08/28/24, 12:06 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/64416

  15. Stefan Bürk commented on patch set 4 08/28/24, 17:16

    Reply

    I'd say execution `extension:setup` is more than enough. That emits the PSR-14 event `PackagesMayHaveChangedEvent`. `TYPO3\CMS\Core\Package\PackageManager` listens on that event `packagesMayHaveChanged()` and executes a new scan of available packages (TBH not tested, just from reading code) - only for non-composer mode. Args - that needs testing - of nothing has changed (no new packages) orderin is not applied as it seems. Maybe we should investigate that first and recondiser that. The cache:warmup command emits also a event the package manager listens, but it also only operates if nothing has been loaded before in non-composer mode. I'd say there is no "simple" way of reordering that. I guess we should fix that in some way first. Without that some needs to either delete the PackageStates.php file or deactive/activate any extension to get it reorderd (which is a weired recommendation for an important rest file anyway). ``` protected function registerPackagesFromConfiguration(array $packages, $registerOnlyNewPackages = false) { $packageStatesHasChanged = false; foreach ($packages as $packageKey => $stateConfiguration) { // ... } if ($packageStatesHasChanged) { $this->sortAndSavePackageStates(); } } ``` I guess we should call sortAndSavePackageStates() anyway or change it to something to save it if resorting changed the order or something else. Something like that. What do you think ? Beside that, I'm fine with 12.4 backport.
  16. Christian Kuhn commented on patch set 4 CR +1 08/28/24, 20:56

    having that suggest in ext_emconf is imho fine.
  17. Benjamin Franzke voted on patch set 4 CR +1 V +1 08/29/24, 08:32

  18. Benjamin Franzke commented on patch set 4 08/29/24, 08:35

    Reply

    Let's try to be very passive with existing installations. I think it's fine to just ship it as-is to 12.4. Installations that needed widgets would already have noticed that, so I don't see an urgent need to update the `PackageStates.php` for everyone.
  19. Stefan Bürk commented on patch set 4 CR +1 V +1 08/30/24, 18:39

    Reply

    I'd say we can discuss this on the dedicated change https://review.typo3.org/c/Packages/TYPO3.CMS/+/85833 but should not be the blocker for this one yet. (I'd say most agency disabled dashboad/not installed it anyway).
  20. Garvin Hicking voted on patch set 4 CR +2 V +2 09/02/24, 14:07

  21. Garvin Hicking merged patch set 5 09/02/24, 14:07