Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[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

Closed
wants to merge 2 commits into from

Conversation

everzet
Copy link
Contributor

@everzet everzet commented Jun 6, 2013

Fixes broken exit codes for console component.

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
New test cases? yes
Tests pass? yes
Fixed tickets 8183, 8202
License MIT
  • Prevent negative and 0 exit code from being used on exception
  • Prevent 255+ exit code from being used

everzet added 2 commits June 6, 2013 16:18
- 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())));
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tobion prove it.

Copy link
Contributor

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.

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

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.

@everzet
Copy link
Contributor Author

everzet commented Jun 6, 2013

@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.

@everzet everzet closed this Jun 6, 2013
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.

3 participants