diff --git a/core/lib/Drupal/Core/CoreBundle.php b/core/lib/Drupal/Core/CoreBundle.php index ba4e3edef05..411a3bd3093 100644 --- a/core/lib/Drupal/Core/CoreBundle.php +++ b/core/lib/Drupal/Core/CoreBundle.php @@ -288,7 +288,7 @@ class CoreBundle extends Bundle { $container->register('exception_controller', 'Drupal\Core\ExceptionController') ->addArgument(new Reference('content_negotiation')) ->addMethodCall('setContainer', array(new Reference('service_container'))); - $container->register('exception_listener', 'Drupal\Core\EventSubscriber\ExceptionListener') + $container->register('exception_listener', 'Symfony\Component\HttpKernel\EventListener\ExceptionListener') ->addTag('event_subscriber') ->addArgument(array(new Reference('exception_controller'), 'execute')); diff --git a/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php b/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php deleted file mode 100644 index f71b35136ca..00000000000 --- a/core/lib/Drupal/Core/EventSubscriber/ExceptionListener.php +++ /dev/null @@ -1,83 +0,0 @@ -controller = $controller; - } - - public function onKernelException(GetResponseForExceptionEvent $event) { - static $handling; - - if ($handling) { - return FALSE; - } - - $handling = TRUE; - - $exception = $event->getException(); - $request = $event->getRequest(); - // Do not put a line in the server logs for every HTTP error. - if (!$exception instanceof HttpExceptionInterface || $exception->getStatusCode() >= 500) { - error_log(sprintf('Uncaught PHP Exception %s: "%s" at %s line %s', get_class($exception), $exception->getMessage(), $exception->getFile(), $exception->getLine())); - } - - $attributes = array( - '_controller' => $this->controller, - 'exception' => FlattenException::create($exception), - 'logger' => NULL, - 'format' => $request->getRequestFormat(), - ); - - $request = $request->duplicate(NULL, NULL, $attributes); - $request->setMethod('GET'); - - try { - $response = $event->getKernel()->handle($request, HttpKernelInterface::SUB_REQUEST, TRUE); - } - catch (\Exception $e) { - $message = sprintf('Exception thrown when handling an exception (%s: %s)', get_class($e), $e->getMessage()); - error_log($message); - // Set handling to false otherwise it won't be able to handle further - // exceptions. - $handling = FALSE; - return; - } - - $event->setResponse($response); - $handling = FALSE; - } - - public static function getSubscribedEvents() { - return array( - KernelEvents::EXCEPTION => array('onKernelException', -128), - ); - } -} diff --git a/core/lib/Drupal/Core/ExceptionController.php b/core/lib/Drupal/Core/ExceptionController.php index c8c6a34b82a..807efae9d37 100644 --- a/core/lib/Drupal/Core/ExceptionController.php +++ b/core/lib/Drupal/Core/ExceptionController.php @@ -13,7 +13,6 @@ use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpKernel\Exception\FlattenException; -use Drupal\Core\EventSubscriber\ExceptionListener; /** * This controller handles HTTP errors generated by the routing system.