Review main Merged

95143[TASK] Add autocomplete to commands of EXT:core

Tobias Gaertner CR +2 V +2 Easy +37 −3 updated 09/01/26, 21:09

Commit message

Add value completion to the following command inputs:

- CacheFlushCommand: option --group
- CacheWarmupCommand: option --group
- SiteShowCommand: argument identifier

The cache groups are resolved from CacheManager::getCacheGroups()
of the container which has already been booted by
CommandApplication, extended by the pseudo groups "di" and "all"
that are handled by the commands themselves.

Left out on purpose: the option --groups of cache:flushtags takes
comma separated values and the wizard identifiers of upgrade:run
and upgrade:mark:undone come from the registry. Both need their
own CompletionInput aware callback and are done in a follow up.

Review

  • Code review CR +2 Done
    • Georg Ringer +2
    • Stefan Bürk +1
    • Benni Mack +1
  • Verified V +2 Done
    • Georg Ringer +2
    • Stefan Bürk +1
    • Benni Mack +1
    • core-ci +1 CI

Issues 1

Files 3

Review log 1619

  1. Tobias Gaertner uploaded patch set 1 08/06/26, 20:35

  2. core-ci voted on patch set 1 V +1 08/06/26, 20:45 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106051

  3. Georg Ringer voted on patch set 1 CR +1 V +1 08/06/26, 20:52

  4. Georg Ringer voted on patch set 1 CR +2 V +2 08/06/26, 20:54

  5. Georg Ringer voted on patch set 1 CR +1 V +1 08/06/26, 20:59

  6. Wouter Wolters voted on patch set 1 CR +1 V +1 08/10/26, 20:00

  7. Stefan Bürk commented on patch set 1 CR -1 08/10/26, 21:37

    Nice, but I have minor remarks.

    CacheFlushCommand.php:54

    Maybe I'm wrong, but that is only a hardcoded list. If we start with autocomplete this should be more a callback function, ensuring the system groups but also support custom cache groups, which can be configured (reading `$container->get(CacheManager::class)->getCacheGroups()`)

    CacheWarmupCommand.php:64

    Maybe I'm wrong, but that is only a hardcoded list. If we start with autocomplete this should be more a callback function, ensuring the system groups but also support custom cache groups, which can be configured (reading `$container->get(CacheManager::class)->getCacheGroups()`)
  8. Georg Ringer uploaded patch set 2 CR +1 V +1 08/15/26, 08:16

  9. Georg Ringer commented on patch set 2 08/15/26, 08:17

    CacheFlushCommand.php:54 Reply

    Done

    CacheWarmupCommand.php:64 Reply

    Done
  10. core-ci voted on patch set 2 V +1 08/15/26, 08:24 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106754

  11. Stefan Bürk commented on patch set 2 CR -1 08/15/26, 18:49

    Thanks for the rework - patch set 2 answers my -1 in substance: the groups are now resolved from CacheManager::getCacheGroups(), and appending the two pseudo groups di and all is exactly right, since getCacheGroups() returns only system, pages here (di is rewritten to a group membership in ServiceProvider::getCacheManager(), and all is command-level). Using the $suggestedValues parameter instead of a hand-rolled complete() override is also the right call - it removes the whole "wrong option name in mustSuggestOptionValuesFor()" class of silent bug. -1 for one thing only, and it is a one-word fix per file. getAvailableCacheGroups() must not call $this->bootService->loadExtLocalconfDatabase(). In the _complete path that boot has already happened: _complete is a Symfony built-in and is not in CommandRegistry, so CommandApplication::wantsFullBoot() returns true and run() calls loadExtLocalconfDatabase() before the console application starts. That method has no idempotency guard - it re-requires every ext_localconf.php and dispatches BootCompletedEvent again. Measured here on a plain instance: boot #1: 111.8 ms, SC_OPTIONS[...][processDatamapClass] entries: 18 boot #2: 10.3 ms, SC_OPTIONS[...][processDatamapClass] entries: 28 after CommandApplication boot: BootCompletedEvent listener calls = 1 after completion closure : BootCompletedEvent listener calls = 2 So one TAB press on "cache:flush -g " duplicates ten core hook registrations and runs every third-party BootCompletedEvent listener twice. BootService documents the method as "can potentially fatal if some old extension is loaded that triggers a fatal in ext_localconf code! Use only if really needed" - a TAB press does not qualify. The cheap variant gives the identical result: A) getContainer()->get(CacheManager::class)->getCacheGroups(): 1.4 ms => system,pages B) loadExtLocalconfDatabase()->get(CacheManager::class)->getCacheGroups(): 9.5 ms => system,pages and it also works on a not-yet-installed instance, where run() skips the boot but still builds the container: boot.state->complete is already true from Bootstrap::init(), so the ServiceProvider::getCacheManager() guard does not trip. I checked that specifically because I expected the opposite. The merged impexp completion (92733) does exactly this - it reads TcaSchemaFactory from the booted container and boots nothing. To correct one thing I wrote on the backport before checking it here: loadExtLocalconfDatabase() does not rebuild $GLOBALS['TCA'] or reload TcaSchemaFactory in any meaningful sense - TcaSchemaFactory::load() early-returns and only the TCA cache file is re-required, about 10 ms. The duplicate ext_localconf registrations and the second BootCompletedEvent dispatch are the real cost, and they are enough. Three smaller points: 1. Please make getAvailableCacheGroups() private rather than protected. Neither command class is final or @internal, so protected adds the same new inherited member to two extendable classes - and via the 14.3 backport, in a patch release. The closure is in-class and $this-bound, so private works unchanged and the five-line duplication becomes harmless. 2. cache:flushtags has the very same -g/--groups option and stays silent. Its value is comma-separated (GeneralUtility::trimExplode(',', ...)), so doing it properly needs a CompletionInput-aware closure that splits on the last comma - fine to defer, but please say so in the commit message. Same for upgrade:run / upgrade:mark:undone, whose wizard identifiers are the most obvious enumerable input left in EXT:core. 3. Commit message: it says CacheWarmupCommand: groups / CacheFlushCommand: groups, but the option is --group (singular) in both - groups belongs to the untouched CacheFlushTagsCommand. Also "the following arguments" - two of the three are options. #107247's description carries the same typo and could be fixed along the way. On the changelog: a new .rst is not needed, #106839 covers the feature. But that file keeps a list of "commands that already provide completion" (redirects:cleanup, redirects:checkintegrity, styleguide:generate). 90309 and the styleguide change maintained it, 92733 did not, and it is now stale. Either extend it here (cache:flush, cache:warmup, site:show, plus the missing impexp:export) or let us agree across the series to drop the enumeration - a list that is right for half its entries is worse than none. Releases: main, 14.3 is fine by me. For the record the family is inconsistent (redirects and styleguide went main only, impexp went to both); with the private fix above there is nothing risky left in the LTS half, so let us keep "both" and settle the series on that. Finally, a follow-up suggestion rather than a condition: core has no console completion test at all - nothing references CommandCompletionTester in any Tests/ directory. CacheFlushCommandTest and CacheWarmupCommandTest already exist and already spawn a real bin/typo3 via AbstractCommandTestCase::executeConsoleCommand(), so asserting "_complete ... --input=cache:flush --input=--group=" is a three-line addition - and it would pin the "boots exactly once" property permanently. A SiteShowCommandTest covering "sites present -> identifiers" and "no config/sites -> empty, no exception" would additionally answer Markus' question on the backport mechanically. Worth tracking on #106839. Once this is updated, please re-cherry-pick 95147 from the final patch set here - it is still at patch set 1 with the hardcoded arrays under the same Change-Id, and it should not merge before this one. Verified: leaving core-ci's +1 alone, I have not built the patched tree locally.

    CacheFlushCommand.php:54 Reply

    Reopening this thread, because the -1 I raised here is answered in a way that introduces a different problem in the same lines. Resolving the groups from CacheManager::getCacheGroups() is exactly right. The part I have to come back on is $this->bootService->loadExtLocalconfDatabase() inside the closure: by the time a suggestion callback runs, CommandApplication::run() has already performed that boot, because _complete is a Symfony built-in and not in CommandRegistry, so wantsFullBoot() is true. The method has no idempotency guard, so the second call re-requires every ext_localconf.php and dispatches BootCompletedEvent again - measured here, SC_OPTIONS[...][processDatamapClass] grows from 18 to 28 entries and a BootCompletedEvent listener is invoked twice, for one TAB press. getContainer()->get(CacheManager::class)->getCacheGroups() returns the identical list in 1.4 ms instead of 9.5 ms, and it also holds on a not-yet-installed instance: run() skips the boot there, but boot.state->complete is already true from Bootstrap::init(), so the ServiceProvider::getCacheManager() guard does not trip. Details and the measurements are in my patchset-level comment. While here: please make the method private rather than protected - the class is neither final nor @internal, and the 14.3 backport would add the inherited member in a patch release.

    CacheWarmupCommand.php:64 Reply

    Reopening this thread, because the -1 I raised here is answered in a way that introduces a different problem in the same lines. Resolving the groups from CacheManager::getCacheGroups() is exactly right. The part I have to come back on is $this->bootService->loadExtLocalconfDatabase() inside the closure: by the time a suggestion callback runs, CommandApplication::run() has already performed that boot, because _complete is a Symfony built-in and not in CommandRegistry, so wantsFullBoot() is true. The method has no idempotency guard, so the second call re-requires every ext_localconf.php and dispatches BootCompletedEvent again - measured here, SC_OPTIONS[...][processDatamapClass] grows from 18 to 28 entries and a BootCompletedEvent listener is invoked twice, for one TAB press. getContainer()->get(CacheManager::class)->getCacheGroups() returns the identical list in 1.4 ms instead of 9.5 ms, and it also holds on a not-yet-installed instance: run() skips the boot there, but boot.state->complete is already true from Bootstrap::init(), so the ServiceProvider::getCacheManager() guard does not trip. Details and the measurements are in my patchset-level comment. While here: same here: please make the method private rather than protected - the class is neither final nor @internal, and the 14.3 backport would add the inherited member in a patch release.
  12. Stefan Bürk commented on patch set 2 CR 0 08/27/26, 15:22

    Reply

    I'v been told to be blocking, so closing this - ignore it.

    CacheFlushCommand.php:54 Reply

    I'v been told to be blocking, so closing this - ignore it.

    CacheWarmupCommand.php:64 Reply

    I'v been told to be blocking, so closing this - ignore it.
  13. Stefan Bürk commented on patch set 2 08/27/26, 15:22

    CacheWarmupCommand.php:64 Reply

    Done
  14. Georg Ringer uploaded patch set 3 V +1 08/27/26, 15:54

  15. core-ci voted on patch set 3 V +1 08/27/26, 16:01 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107278

  16. Stefan Bürk voted on patch set 3 CR +1 V +1 09/01/26, 20:30

  17. Benni Mack voted on patch set 3 CR +1 V +1 09/01/26, 21:08

  18. Georg Ringer voted on patch set 3 CR +2 V +2 09/01/26, 21:09

  19. Georg Ringer merged patch set 4 09/01/26, 21:09