-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Console] Fix restoring exception handler #25753
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
nicolas-grekas
commented
Jan 10, 2018
Q | A |
---|---|
Branch? | 3.4 |
Bug fix? | yes |
New feature? | no |
BC breaks? | no |
Deprecations? | ,p |
Tests pass? | yes |
Fixed tickets | #25718 |
License | MIT |
Doc PR | - |
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.
looks reasonable to me. though i think some doc comments would really help here to understand why/what we do here.
@@ -164,6 +164,9 @@ public function run(InputInterface $input = null, OutputInterface $output = null | |||
} | |||
} finally { | |||
if (!$phpHandler) { | |||
if (set_exception_handler($renderException) === $renderException) { |
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.
I agree with @dbu to either add comments or extract some private methods. Also I don't get how this solves the problem. From how I understood #25718, the Kernel exception handler is set after the console one. So set_exception_handler($renderException) === $renderException
is not true. And even if it is true, this block only sets an exception handler that is then removed again?
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.
I think the code is correct. The only way to learn the current handler is to overwrite it. If condition is true, we pop it out again. Then either way we pop one more time. If condition was true, that removes the actual handler, otherwise it pops the thing we set to learn what handler was set.
I would happily add a comment, but I've no inspiration (maybe because I feel like the code is enough...) |
2489487
to
0096449
Compare
Thank you @fancyweb. |
… fancyweb) This PR was merged into the 3.4 branch. Discussion ---------- [Console] Fix restoring exception handler | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | ,p | Tests pass? | yes | Fixed tickets | #25718 | License | MIT | Doc PR | - Commits ------- 0096449 [Console] Keep the modified exception handler 3fa1ad9 [Console] Fix restoring exception handler