bug #25753 [Console] Fix restoring exception handler (nicolas-grekas, 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
This commit is contained in:
Nicolas Grekas 2018-01-16 18:26:02 +01:00
commit d8d85f17b5

View File

@ -163,10 +163,18 @@ class Application
$exitCode = 1;
}
} finally {
// if the exception handler changed, keep it
// otherwise, unregister $renderException
if (!$phpHandler) {
if (set_exception_handler($renderException) === $renderException) {
restore_exception_handler();
}
restore_exception_handler();
} elseif (!$debugHandler) {
$phpHandler[0]->setExceptionHandler(null);
$finalHandler = $phpHandler[0]->setExceptionHandler(null);
if ($finalHandler !== $renderException) {
$phpHandler[0]->setExceptionHandler($finalHandler);
}
}
}