bug #25829 [Debug] Always decorate existing exception handlers to deal with fatal errors (nicolas-grekas)

This PR was merged into the 2.7 branch.

Discussion
----------

[Debug] Always decorate existing exception handlers to deal with fatal errors

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

Decorating the exception is seamless, let's always do it and fix handling of fatal errors.
Related to #25408 also.

Commits
-------

205d7ae3f7 [Debug] Always decorate existing exception handlers to deal with fatal errors
This commit is contained in:
Fabien Potencier 2018-01-18 13:12:09 +01:00
commit 78a8a63450
1 changed files with 6 additions and 3 deletions

View File

@ -147,11 +147,14 @@ class ErrorHandler
$handler = $prev[0];
$replace = false;
}
if ($replace || !$prev) {
$handler->setExceptionHandler(set_exception_handler(array($handler, 'handleException')));
} else {
if (!$replace && $prev) {
restore_error_handler();
}
if (is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] === $handler) {
restore_exception_handler();
} else {
$handler->setExceptionHandler($prev);
}
$handler->throwAt($levels & $handler->thrownErrors, true);