-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Ensure proper exit code on Exception #8217
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
- Prevent negative and 0 exit code from being used on exception - Prevent 255+ exit code from being used Fixes symfony#8183, symfony#8202
|
||
$statusCode = is_numeric($statusCode) && $statusCode ? (int) $statusCode : 1; | ||
$statusCode = max(1, min(254, intval($e->getCode()))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I already said, this changes behavior and breaks BC considerably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Provide a failing test case to support your statement. Cuz I have 5 passing ones that only prove mine - behaviour is not changed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So your claim in the description, it does not break bc is wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tobion prove it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, you really don't see it apparently:
Just set $this->autoExit = false and let $e->getCode() return something greater than 255. Result is different before and after.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The funny thing is, that you even have a test for it. You just need to run it without your changes applied. And you will see it fail...^^
5 passing ones that only prove mine - behaviour is not changed.
so you probably mean the opposite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. Thanks for pointing this one out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is another bc break and code error:
Let $e->getCode()
return an object. You will receive a php notice.
@Tobion Ok, I stopped caring about fix for obviously broken behaviour. What still bothers me though is a BC break that already happened across the board (2.1, 2.2, 2.3), which breaks every single Symfony2 console application out there (including Behat, PhpSpec and others). The question is, why didn't you bother that much about BC breaks when you commited that in the first place: 5c317b7 ? Just roll your commit back from 2.1, 2.2 & 2.3 and we're done. |
Fixes broken exit codes for console component.