Skip to content

[4.x] Make BeforeCommandExecuteEvent::enableCommand() enable the command - #31

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

Hackwar wants to merge 1 commit into
joomla-framework:4.x-devfrom
Hackwar:4.x-enable-command

Conversation

@Hackwar

@Hackwar Hackwar commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Summary of Changes

BeforeCommandExecuteEvent::enableCommand() set the enabled flag to false, a copy of disableCommand(). A BEFORE_COMMAND_EXECUTE listener that tried to enable (or re-enable) a command actually disabled it: the command was not run and the application exited with RETURN_CODE_DISABLED (113). The method now sets the flag to true.

Testing Instructions

  • tests/Event/BeforeCommandExecuteEventTest.php covers the default state, disableCommand() and disableCommand() followed by enableCommand().
  • ApplicationTest::testCommandIsExecutedIfEventEnablesCommandAgain registers one listener that disables the command and a second, lower-priority one that enables it again, and asserts the command runs with exit code 0.

Both fail on 4.x-dev (isCommandEnabled() returns false, the command is not executed) and pass with this change. vendor/bin/phpunit, phpcs and PHPStan are clean.

Documentation Changes Required

docs/overview.md: the BEFORE_COMMAND_EXECUTE entry now names disableCommand()/enableCommand() and the exit code 113 for a disabled command.

🤖 Generated with Claude Code

enableCommand() set the enabled flag to false, a copy of
disableCommand(). A listener that tried to enable a command therefore
disabled it, and the application returned RETURN_CODE_DISABLED (113)
without running the command.

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

Hackwar commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

This fixes a genuine bug.

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.

2 participants