diff --git a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php index 95eb8a81f9..477d79a952 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php +++ b/src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php @@ -28,9 +28,9 @@ class ExceptionController extends Controller * * @throws \InvalidArgumentException When the exception template does not exist */ - public function exceptionAction(ExceptionManager $manager) + public function exceptionAction(ExceptionManager $manager, $format) { - $this['request']->setRequestFormat($manager->getFormat()); + $this['request']->setRequestFormat($format); $currentContent = ''; while (false !== $content = ob_get_clean()) { diff --git a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionListener.php b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionListener.php index 7348dabc35..a1e76c0c61 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionListener.php +++ b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionListener.php @@ -7,6 +7,7 @@ use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\Event; use Symfony\Component\HttpKernel\Log\LoggerInterface; use Symfony\Component\HttpKernel\HttpKernelInterface; +use Symfony\Component\HttpFoundation\Request; /* * This file is part of the Symfony framework. @@ -53,6 +54,7 @@ class ExceptionListener } $exception = $event->getParameter('exception'); + $request = $event->getParameter('request'); if (null !== $this->logger) { $this->logger->err(sprintf('%s: %s (uncaught exception)', get_class($exception), $exception->getMessage())); @@ -65,10 +67,12 @@ class ExceptionListener $attributes = array( '_controller' => $this->controller, - 'manager' => new $class($exception, $event->getParameter('request'), $logger), + 'manager' => new $class($exception, $logger), + // when using CLI, we force the format to be TXT + 'format' => 0 === strncasecmp(PHP_SAPI, 'cli', 3) ? 'txt' : $request->getRequestFormat(), ); - $request = $event->getParameter('request')->duplicate(null, null, $attributes); + $request = $request->duplicate(null, null, $attributes); try { $response = $event->getSubject()->handle($request, HttpKernelInterface::SUB_REQUEST, true); diff --git a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php index e958311d0b..8a73d4dcc5 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php +++ b/src/Symfony/Bundle/FrameworkBundle/Debug/ExceptionManager.php @@ -4,7 +4,6 @@ namespace Symfony\Bundle\FrameworkBundle\Debug; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpKernel\Exception\HttpException; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; @@ -25,13 +24,11 @@ use Symfony\Component\HttpKernel\Log\DebugLoggerInterface; class ExceptionManager { protected $exception; - protected $request; protected $logger; - public function __construct(\Exception $exception, Request $request, DebugLoggerInterface $logger = null) + public function __construct(\Exception $exception, DebugLoggerInterface $logger = null) { $this->exception = $exception; - $this->request = $request; $this->logger = $logger; } @@ -40,7 +37,7 @@ class ExceptionManager $managers = array(); $e = $this->exception; while ($e = $e->getPrevious()) { - $managers[] = new $this($e, $this->request); + $managers[] = new $this($e); } return $managers; @@ -77,18 +74,6 @@ class ExceptionManager return $errors; } - public function getFormat() - { - $format = $this->request->getRequestFormat(); - - // when using CLI, we force the format to be TXT - if (0 === strncasecmp(PHP_SAPI, 'cli', 3)) { - $format = 'txt'; - } - - return $format; - } - public function getStatusCode() { return $this->exception instanceof HttpException ? $this->exception->getCode() : 500;