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

Skip to content

[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

Merged
merged 2 commits into from
Jan 16, 2018

Conversation

nicolas-grekas
Copy link
Member

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 -

Copy link
Contributor

@dbu dbu left a 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) {
Copy link
Contributor

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?

Copy link
Contributor

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.

@nicolas-grekas
Copy link
Member Author

I would happily add a comment, but I've no inspiration (maybe because I feel like the code is enough...)
Suggestions welcomed if you think we should add one.

@nicolas-grekas
Copy link
Member Author

Thank you @fancyweb.

@nicolas-grekas nicolas-grekas merged commit 0096449 into symfony:3.4 Jan 16, 2018
nicolas-grekas added a commit that referenced this pull request Jan 16, 2018
… 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
@nicolas-grekas nicolas-grekas deleted the console-ex branch January 16, 2018 17:26
This was referenced Jan 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants