Skip to content

Commit

Permalink
bug #25829 [Debug] Always decorate existing exception handlers to dea…
Browse files Browse the repository at this point in the history
…l 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
-------

205d7ae [Debug] Always decorate existing exception handlers to deal with fatal errors
  • Loading branch information
fabpot committed Jan 18, 2018
2 parents 5d39415 + 205d7ae commit 78a8a63
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Symfony/Component/Debug/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,14 @@ public static function register($handler = null, $replace = true)
$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);

Expand Down

0 comments on commit 78a8a63

Please sign in to comment.