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

This commit is contained in:
Nicolas Grekas 2018-01-18 09:54:17 +01:00
parent 3a8f905e10
commit 205d7ae3f7
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);