-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] fixed PHP7 Errors are now handled in Application::run and a… #20917
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
… proper status code is returned
b915049
to
779ccc6
Compare
In #20808, I adopt another approach, because catching I.e, with your proposal, you'll get:
instead of the current:
See #20808 (comment) and #19813 (comment) Note that you only get a 0 exit code when a command throws an I just realized there is an inconsistency in 899fa79 because, using the component standalone:
It should always throw the original In #20797 I try to fix the issue with commands throwing WDYT? |
I was guided by the #20736, to have a simple fix for the problem. Rethrow the original exception in case of \Exception, wrap it in FatalThrowableError otherwise. In any case, which ever solution is chosen, it should go to the 2.7 branch. PHP 7 is being deployed at a fast pace, anybody using symfony and relying on the command exit code will be in for a nasty surprise. |
#20797 targets 2.7 and solves this issue. |
Can we close this one? |
The issue of 0 exit code for throwable exceptions when console is used within the symfony framework on php 7 still exists (due to the DebugHandlersListener). The fix for this can be either in the Console/Application::run (this PR), or directly in the DebugHandlersListener (PR #20797). We've been using this fork in production for 3 months, to avoid problems with cli queue workers. |
The wrong exit code has been fixed and |
PRs #19813 and #20736 do not complete solve every problem with PHP7 new \Error class. This PR adds additional catching in Application::run, and as such the Application now returns status code 1 when \Error occurs, and closes #20775.
More info:
If there is no dispatcher, due to #20736 everything will work fine, FatalThrowableError will be rethrown, and that is catched by the try/catch in Application::run.
When there is a dispatcher, but there is no console.exception Listener that modifies the exception, code in PR #19813 will rethrow the original exception (\Error), and not the wrapped one. Since Application:run only catches Exceptions \Error will not get caught by try/catch in Application::run, and as a result status code will be 0, which is obviously wrong.