Explorar o código

[FrameworkBundle] Ensuring the exception page renders even when the Request format is unknown to Symfony

Jordi Boggiano %!s(int64=14) %!d(string=hai) anos
pai
achega
e7ea2eb433

+ 9 - 2
src/Symfony/Bundle/FrameworkBundle/Controller/ExceptionController.php

@@ -46,8 +46,15 @@ class ExceptionController extends ContainerAware
             $exception->setStatusCode($exception->getCode());
         }
 
-        $response = $this->container->get('templating')->renderResponse(
-            'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php'),
+        $templating = $this->container->get('templating');
+        $template = 'FrameworkBundle:Exception:'.($this->container->get('kernel')->isDebug() ? 'exception.php' : 'error.php');
+
+        if (!$templating->exists($template)) {
+            $this->container->get('request')->setRequestFormat('html');
+        }
+
+        $response = $templating->renderResponse(
+            $template,
             array(
                 'exception'      => $exception,
                 'logger'         => $logger,