From 3fa1ad9c81c96b826da5973883fce204e5389973 Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Wed, 10 Jan 2018 18:47:32 +0100 Subject: [PATCH 1/2] [Console] Fix restoring exception handler --- src/Symfony/Component/Console/Application.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index be283aad16..627be50679 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -163,7 +163,12 @@ class Application $exitCode = 1; } } finally { + // if the exception handler changed, keep it + // otherwise, unregister $renderException if (!$phpHandler) { + if (set_exception_handler($renderException) === $renderException) { + restore_exception_handler(); + } restore_exception_handler(); } elseif (!$debugHandler) { $phpHandler[0]->setExceptionHandler(null); From 00964492d270b8b06ea88d645ea59674f787e3c2 Mon Sep 17 00:00:00 2001 From: Thomas Calvet Date: Fri, 12 Jan 2018 14:11:07 +0100 Subject: [PATCH 2/2] [Console] Keep the modified exception handler --- src/Symfony/Component/Console/Application.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Symfony/Component/Console/Application.php b/src/Symfony/Component/Console/Application.php index 627be50679..107c1ed6ca 100644 --- a/src/Symfony/Component/Console/Application.php +++ b/src/Symfony/Component/Console/Application.php @@ -171,7 +171,10 @@ class Application } restore_exception_handler(); } elseif (!$debugHandler) { - $phpHandler[0]->setExceptionHandler(null); + $finalHandler = $phpHandler[0]->setExceptionHandler(null); + if ($finalHandler !== $renderException) { + $phpHandler[0]->setExceptionHandler($finalHandler); + } } }