8000 [Console] Exit status is 0 on PHP7 when there is a \Throwable exception · Issue #18484 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Console] Exit status is 0 on PHP7 when there is a \Throwable exception #18484

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
acasademont opened this issue Apr 8, 2016 · 4 comments
Closed

Comments

@acasademont
Copy link
Contributor

Hi!

Pretty basic example

<?php
$a = null;
$a->getId();

This in PHP7 will throw an \Error, which implements the \Throwable interface. However, on https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L118 we are only catching \Exception to set the status code to 1. As a result, those especial exceptions in the console end up with an 0 exit status code, when it should be 1 as with all other normal exceptions. Thanks! Can work on a PR if needed :)

@acasademont acasademont changed the title [Console] Exit status is 0 on PHP7 when there is an \Throwable exception [Console] Exit status is 0 on PHP7 when there is a \Throwable exception Apr 8, 2016
@linaori
Copy link
Contributor
linaori commented Apr 8, 2016

There's going to be a small problem with this method though: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Console/Application.php#L606

Maybe you could extract the logic or even extract the exception handling away.

@acasademont
Copy link
Contributor Author

Yeah sure, this not as easy as changing the \Exception for a \Throwable, we would be breaking all PHP5 installs. Some work needs to be done.

8000

@GrahamCampbell
Copy link
Contributor

changing the \Exception for a \Throwable, we would be breaking all PHP5 installs

Just do what the rest of symfony has done, and use symfony's exception classes to get around this.

@GrahamCampbell
Copy link
Contributor

Check if instanceof throwable and not instanceof exception, then if that's true, create this: https://github.com/symfony/symfony/blob/master/src/Symfony/Component/Debug/Exception/FatalThrowableError.php, and pass it trough instad.

fonsecas72 pushed a commit to fonsecas72/symfony that referenced this issue Sep 6, 2016
fonsecas72 pushed a commit to fonsecas72/symfony that referenced this issue Sep 6, 2016
fabpot added a commit that referenced this issue Sep 8, 2016
…to Exceptions (fonsecas72)

This PR was squashed before being merged into the 2.7 branch (closes #19813).

Discussion
----------

[Console] fixed PHP7 Errors are now handled and converted to Exceptions

| Q             | A
| ------------- | ---
| Branch?       | 2.7
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #18484
| License       | MIT
| Doc PR        |

Commits
-------

d3c613b [Console] fixed PHP7 Errors are now handled and converted to Exceptions
@fabpot fabpot closed this as completed Sep 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants
0