Skip to content

Commit 78a8a63

Browse files
committed
bug symfony#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 | symfony#25827 | License | MIT | Doc PR | - Decorating the exception is seamless, let's always do it and fix handling of fatal errors. Related to symfony#25408 also. Commits ------- 205d7ae [Debug] Always decorate existing exception handlers to deal with fatal errors
2 parents 5d39415 + 205d7ae commit 78a8a63

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)