95147[TASK] Add autocomplete to commands of EXT:core
Commit message
Review
-
Code review CR +2 Done
- Georg Ringer +2
- Stefan Bürk +1
-
Verified V +2 Done
- Georg Ringer +2
- Stefan Bürk +1
- core-ci +1 CI
Issues 1
Files 3
Review log 1012
-
Georg Ringer commented on patch set 1 08/06/26, 20:54
Cherry Picked from branch main. -
core-ci voted on patch set 1 V +1 08/06/26, 21:05 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/106057
-
Wouter Wolters voted on patch set 1 CR +1 V +1 08/10/26, 20:01
-
Markus Klein commented on patch set 1 08/14/26, 22:22
Does that somehow fail, if no site exists yet, or if the instance is not really set up yet? -
Stefan Bürk commented on patch set 1 CR -1 08/15/26, 18:07
Thanks for splitting this up per extension. The direction is right, and using the $suggestedValues constructor parameter instead of a hand-rolled complete() override is the correct choice here - it makes the "wrong option name in mustSuggestOptionValuesFor()" class of silent bug structurally impossible. -1 for one reason only: this backport has diverged from its main counterpart. 95143 got a -1 on the hardcoded cache-group lists and is now at patch set 2, where both cache commands resolve the groups dynamically via CacheManager::getCacheGroups(). This change is still patch set 1 with the hardcoded arrays, under the same Change-Id. Please re-cherry-pick from the final main patch set once 95143 is merged, and let 95143 go in first. (For the record, the +1 here was cast about 90 minutes before the -1 landed on main - no blame, it is exactly the kind of drift that is hard to see across two changes.) Three things to carry into the refreshed backport - they are really remarks on 95143 ps2, but they will land here verbatim: 1. getAvailableCacheGroups() calls $this->bootService->loadExtLocalconfDatabase(). In the _complete path CommandApplication::run() has already called it, and that method is not idempotent - it re-loads ext_localconf, rebuilds $GLOBALS['TCA'], reloads TcaSchemaFactory and dispatches BootCompletedEvent a second time. So every TAB press on "cache:flush -g " boots twice and fires BootCompletedEvent twice, meaning every third-party listener runs twice. The container is already fully booted at that point; reading the current container gives the same list for free. 2. The identical getAvailableCacheGroups() is copy-pasted into both command classes. A small shared helper would avoid adding the same new protected method to two classes that carry no @internal marker. 3. cache:flush:tags has the very same -g/--groups option and is left without completion. Having "cache:flush -g <TAB>" suggest while "cache:flush:tags -g <TAB>" stays silent is more confusing than having neither. Two smaller points: * The commit message says CacheWarmupCommand: groups / CacheFlushCommand: groups, but the option is --group (singular) in both - groups is the option of the untouched CacheFlushTagsCommand. * Changelog/14.0/Feature-106839-IntroduceShellAuto-completionForTheTypo3Script.rst keeps a list of "commands that already provide completion". 90309 maintained it, 92733 did not, and it is now stale. Either extend it here (cache:flush, cache:warmup, site:show) or let us agree across this whole series to drop the list - an unmaintained enumeration is worse than none. A new .rst for this change is not needed, #106839 covers the feature. Last, a policy question for the series rather than for this change: Releases: main, 14.3. redirects (90309) went main only, impexp (92733/95330) went to both. This is a behaviour addition to a stable LTS, low risk, and I would not object - but the family should settle on one answer. Unrelated, spotted while looking at the sibling: 95135 has "Resolve: #107249" in its footer instead of "Resolves:", which breaks the forge integration. Finally, a suggestion rather than a condition: core has no test for console completion at all - nothing references CompletionInput / CompletionSuggestions in any Tests/ directory. Symfony's CommandCompletionTester is exactly the tool, and the #106839 changelog already links the upstream testing docs. site:show is the natural first case: sites present -> identifiers suggested, no config/sites directory -> empty result and no exception. A test like that would have caught this backport drifting from main mechanically. Worth a follow-up on the umbrella issue.Reply
No, it does not fail - I traced the whole path. SiteConfiguration::getAllSiteConfigurationFromFiles() catches the \InvalidArgumentException for a missing config/sites directory and falls back to an empty list; InputArgument::complete() then simply skips the empty array. The lookup is filesystem-only and never touches the database, so it also survives a missing settings.php: CommandApplication skips loadExtLocalconfDatabase() in that case but still builds the full container, which is all the callback needs. As a backstop, Symfony's CompleteCommand::execute() catches \Throwable and returns exit code 2, so any failure inside a suggestion callback degrades to "no suggestions" rather than a stack trace in the user's shell. One side effect worth knowing: the lookup writes the resolved site configuration into cache.core, so a TAB press performs a cache write. -
Stefan Bürk commented on patch set 1 08/15/26, 18:49
Reply
Follow-up: I have now reviewed the main change 95143 at patch set 2 as well and left a -1 there - https://review.typo3.org/c/Packages/TYPO3.CMS/+/95143 To be clear about where things should be fixed, so nothing gets done twice or in the wrong place: Fix on main (95143), then re-cherry-pick here - all of it lands in this change automatically: * the loadExtLocalconfDatabase() call in the completion closure (this is the -1 on 95143), * getAvailableCacheGroups() private instead of protected - this one matters more for the backport than for main, because protected adds an inherited member to two non-final, non-@internal command classes in a 14.3 patch release, * the cache:flushtags decision (complete it or state the deferral), * the #106839 "commands that already provide completion" list, * the commit message wording (--group singular, "arguments" vs options). Backport-only, i.e. genuinely this change: * re-cherry-pick from the final 95143 patch set - this is still ps1 with the hardcoded group arrays under the same Change-Id, * the existing Code-Review +1 here was cast against ps1 and predates the -1 on main, so it should not be read as covering the reworked code, * 95143 must merge first. Two corrections to my earlier comment, now that I have measured it on main rather than reasoning from the code: 1. I wrote that loadExtLocalconfDatabase() "rebuilds $GLOBALS['TCA'], reloads TcaSchemaFactory and dispatches BootCompletedEvent a second time". The TCA half of that is wrong: TcaSchemaFactory::load() early-returns and only the TCA cache file is re-required, roughly 10 ms. What is real is that the method has no idempotency guard, so ext_localconf registrations are duplicated (SC_OPTIONS[...][processDatamapClass] goes from 18 to 28 entries) and BootCompletedEvent listeners run twice per TAB press. The conclusion stands, and is in fact a bit stronger than I put it: the boot is not merely redundant, it is never needed - boot.state->complete is already true from Bootstrap::init(), so reading CacheManager from the container works in every CLI state, including a not-yet-installed instance. 2. I wrote cache:flush:tags; the command is actually cache:flushtags. Its --groups value is comma-separated, so completing it properly needs a CompletionInput-aware closure that splits on the last comma - deferring it is fine, it just should be said out loud. Sorry for the noise on both counts. -
Georg Ringer commented on patch set 2
CR +1V +109/01/26, 15:23Cherry Picked from branch main. -
core-ci voted on patch set 2 V +1 09/01/26, 15:31 Core CI is happy: https://git.typo3.org/typo3/CI/cms/-/pipelines/107501
-
Stefan Bürk commented on patch set 2 09/01/26, 20:30
Reply
Done -
Stefan Bürk voted on patch set 2 CR +1 V +1 09/01/26, 20:31
-
Georg Ringer voted on patch set 2 CR +2 V +2 09/01/26, 21:10
-
Georg Ringer merged patch set 3 09/01/26, 21:10