Skip to content

[4.x] Reset the help request when the command lookup fails - #33

Open
Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-reset-wants-help
Open

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-reset-wants-help

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

With --help and a command name that does not exist, doExecute() set the internal $wantsHelp flag and getCommand() threw CommandNotFoundException before it could consume the flag. The flag stayed true after execute() returned, so the next getCommand() call on the same Application instance (tests, long-running processes, applications that dispatch further commands) returned the help command instead of the requested one.

doExecute() now resets the flag in a finally block after the command lookup.

Testing Instructions

ApplicationTest::testHelpRequestForUnknownCommandDoesNotLeakIntoLaterLookups runs the application with ['command' => 'foo', '--help' => true] and then asserts that getCommand('list') returns the ListCommand. On 4.x-dev it returns the HelpCommand; with this change the test passes.

Documentation Changes Required

None. The docs do not describe this internal state.

🤖 Generated with Claude Code

With --help and an unknown command, doExecute() set $wantsHelp and
getCommand() threw before consuming it. The flag stayed set, so the
next getCommand() call on the same application returned the help
command instead of the requested one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Hackwar

Hackwar commented Nov 19, 2026

Copy link
Copy Markdown
Contributor Author

Approved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant