Skip to content

Commit 205d7ae

Browse files
[Debug] Always decorate existing exception handlers to deal with fatal errors
1 parent 3a8f905 commit 205d7ae

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,14 @@ public static function register($handler = null, $replace = true)
147147
$handler = $prev[0];
148148
$replace = false;
149149
}
150-
if ($replace || !$prev) {
151-
$handler->setExceptionHandler(set_exception_handler(array($handler, 'handleException')));
152-
} else {
150+
if (!$replace && $prev) {
153151
restore_error_handler();
154152
}
153+
if (is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] === $handler) {
154+
restore_exception_handler();
155+
} else {
156+
$handler->setExceptionHandler($prev);
157+
}
155158

156159
$handler->throwAt($levels & $handler->thrownErrors, true);
157160

0 commit comments

Comments
 (0)