From d5c54c2fa7141c6caaf0d4d4bb870663ee6b45ee Mon Sep 17 00:00:00 2001 From: Nicolas Grekas Date: Sat, 4 Apr 2020 13:58:35 +0200 Subject: [PATCH] [HttpKernel][FrameworkBundle] fix compat with Debug component --- src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php | 4 ++++ .../HttpKernel/EventListener/DebugHandlersListener.php | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php index b505daf131..0dc2860229 100644 --- a/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php +++ b/src/Symfony/Bundle/FrameworkBundle/FrameworkBundle.php @@ -35,6 +35,7 @@ use Symfony\Component\Cache\DependencyInjection\CachePoolPass; use Symfony\Component\Cache\DependencyInjection\CachePoolPrunerPass; use Symfony\Component\Config\Resource\ClassExistenceResource; use Symfony\Component\Console\DependencyInjection\AddConsoleCommandPass; +use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler; use Symfony\Component\DependencyInjection\Compiler\PassConfig; use Symfony\Component\DependencyInjection\Compiler\RegisterReverseContainerPass; use Symfony\Component\DependencyInjection\ContainerBuilder; @@ -89,6 +90,9 @@ class FrameworkBundle extends Bundle public function boot() { ErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); + if (class_exists(LegacyErrorHandler::class, false)) { + LegacyErrorHandler::register(null, false)->throwAt($this->container->getParameter('debug.error_handler.throw_at'), true); + } if ($this->container->getParameter('kernel.http_method_override')) { Request::enableHttpMethodParameterOverride(); diff --git a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php index dcb54ea891..0e672a299d 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/DebugHandlersListener.php @@ -15,6 +15,7 @@ use Psr\Log\LoggerInterface; use Symfony\Component\Console\ConsoleEvents; use Symfony\Component\Console\Event\ConsoleEvent; use Symfony\Component\Console\Output\ConsoleOutputInterface; +use Symfony\Component\Debug\ErrorHandler as LegacyErrorHandler; use Symfony\Component\Debug\Exception\FatalThrowableError; use Symfony\Component\ErrorHandler\ErrorHandler; use Symfony\Component\EventDispatcher\Event; @@ -79,7 +80,7 @@ class DebugHandlersListener implements EventSubscriberInterface restore_exception_handler(); if ($this->logger || null !== $this->throwAt) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { if ($this->logger) { $handler->setDefaultLogger($this->logger, $this->levels); if (\is_array($this->levels)) { @@ -138,7 +139,7 @@ class DebugHandlersListener implements EventSubscriberInterface } } if ($this->exceptionHandler) { - if ($handler instanceof ErrorHandler) { + if ($handler instanceof ErrorHandler || $handler instanceof LegacyErrorHandler) { $handler->setExceptionHandler($this->exceptionHandler); } $this->exceptionHandler = null;