diff --git a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml index f6dd2bb9df630..3eb58a1433092 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml +++ b/src/Symfony/Bundle/FrameworkBundle/Resources/config/web.xml @@ -68,8 +68,9 @@ - + + null %kernel.debug% diff --git a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php index 4d8ad1e7e5971..07d02c499a7bf 100644 --- a/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php +++ b/src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php @@ -37,6 +37,7 @@ class ExceptionListener implements EventSubscriberInterface protected $debug; private $charset; private $fileLinkFormat; + private $isTerminating = false; public function __construct($controller, LoggerInterface $logger = null, $debug = false, $charset = null, $fileLinkFormat = null) { @@ -49,6 +50,17 @@ public function __construct($controller, LoggerInterface $logger = null, $debug public function onKernelException(GetResponseForExceptionEvent $event) { + if (null === $this->controller) { + if (!$event->isMasterRequest()) { + return; + } + if (!$this->isTerminating) { + $this->isTerminating = true; + + return; + } + $this->isTerminating = false; + } $exception = $event->getException(); $request = $event->getRequest(); $eventDispatcher = func_num_args() > 2 ? func_get_arg(2) : null; @@ -88,6 +100,11 @@ public function onKernelException(GetResponseForExceptionEvent $event) } } + public function reset() + { + $this->isTerminating = false; + } + public static function getSubscribedEvents() { return array( diff --git a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php index b607bf900ae91..26041e6ecb433 100644 --- a/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/EventListener/ExceptionListenerTest.php @@ -165,7 +165,9 @@ public function testNullController() $event = new GetResponseForExceptionEvent($kernel, $request, HttpKernelInterface::MASTER_REQUEST, new \Exception('foo')); $listener->onKernelException($event); + $this->assertNull($event->getResponse()); + $listener->onKernelException($event); $this->assertContains('Whoops, looks like something went wrong.', $event->getResponse()->getContent()); } }