Skip to content

Commit 5a3c7db

Browse files
[ErrorHandler] Fix exit code when an exception occurs and the exception handler has been unregistered
1 parent 90b1d77 commit 5a3c7db

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ErrorHandler.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -669,6 +669,10 @@ public static function handleFatalError(?array $error = null): void
669669
set_exception_handler($h);
670670
}
671671
if (!$handler) {
672+
if (null === $error && $exitCode = self::$exitCode) {
673+
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
674+
}
675+
672676
return;
673677
}
674678
if ($handler !== $h) {
@@ -704,8 +708,7 @@ public static function handleFatalError(?array $error = null): void
704708
// Ignore this re-throw
705709
}
706710

707-
if ($exit && self::$exitCode) {
708-
$exitCode = self::$exitCode;
711+
if ($exit && $exitCode = self::$exitCode) {
709712
register_shutdown_function('register_shutdown_function', function () use ($exitCode) { exit($exitCode); });
710713
}
711714
}

0 commit comments

Comments
 (0)