8000 [Debug] Reset previous exception handler ealier to prevent infinite loop · symfony/symfony@f7e1bb0 · GitHub
[go: up one dir, main page]

Skip to content

Commit f7e1bb0

Browse files
[Debug] Reset previous exception handler ealier to prevent infinite loop
1 parent ffd088a commit f7e1bb0

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/Symfony/Component/Debug/ErrorHandler.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,15 +544,16 @@ public function handleException($exception, array $error = null)
544544
}
545545
}
546546
}
547+
$exceptionHandler = $this->exceptionHandler;
548+
$this->exceptionHandler = null;
547549
try {
548-
if (null !== $this->exceptionHandler) {
549-
return \call_user_func($this->exceptionHandler, $exception);
550+
if (null !== $exceptionHandler) {
551+
return \call_user_func($exceptionHandler, $exception);
550552
}
551553
$handlerException = $handlerException ?: $exception;
552554
} catch (\Exception $handlerException) {
553555
} catch (\Throwable $handlerException) {
554556
}
555-
$this->exceptionHandler = null;
556557
if ($exception === $handlerException) {
557558
self::$reservedMemory = null; // Disable the fatal error handler
558559
throw $exception; // Give back $exception to the native handler

src/Symfony/Component/Debug/Tests/ErrorHandlerTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,4 +530,17 @@ public function testLegacyInterface()
530530
throw $e;
531531
}
532532
}
533+
534+
/**
535+
* @expectedException \Exception
536+
*/
537+
public function testCustomExceptionHandler()
538+
{
539+
$handler = new ErrorHandler();
540+
$handler->setExceptionHandler(function ($e) use ($handler) {
541+
$handler->handleException($e);
542+
});
543+
544+
$handler->handleException(new \Exception());
545+
}
533546
}

0 commit comments

Comments
 (0)
0