-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Send the right exit code to console.terminate listeners #28545
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
3.4 does not have this bug, most likely due to #22441 |
at least tests fail :) |
@nicolas-grekas Will work on tests if you agree we should fix it on 2.8. |
We might also just wait for 2.8 to fade out if you don't have time to work on this :) |
I was expecting this :-) Personally, I‘ll probably have to deal with 2.8 for another year so I‘d be glad to have this fixed. |
@nicolas-grekas Tests added – does it make sense to omit the |
79066c8
to
b90a3f1
Compare
Thank you @mpdude. |
…steners (mpdude) This PR was squashed before being merged into the 2.8 branch (closes #28545). Discussion ---------- [Console] Send the right exit code to console.terminate listeners | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | When a Console command throws an exception without a status code, `Application::run()` takes care of setting the exit code to `1` when the exception does not provide a code itself. This happens slightly too late, as `console.terminate` event listeners that are called from within `Application::doRunCommand()` are given the plain exeception code, before this conversion. The result is that `console.*` event listeners that you might be using to log exit code e. g. for cron jobs will see a `0` code instead of the real value used to terminate the script. ***Todo:*** - [x] Make sure we've got tests covering this, i. e. do not mock out `doRunCommand()`. Commits ------- b90a3f1 [Console] Send the right exit code to console.terminate listeners
When a Console command throws an exception without a status code,
Application::run()
takes care of setting the exit code to1
when the exception does not provide a code itself.This happens slightly too late, as
console.terminate
event listeners that are called from withinApplication::doRunCommand()
are given the plain exeception code, before this conversion.The result is that
console.*
event listeners that you might be using to log exit code e. g. for cron jobs will see a0
code instead of the real value used to terminate the script.Todo:
doRunCommand()
.