10000 merged branch fabpot/exception-format (PR #8819) · enumag/symfony@8ab368d · GitHub
[go: up one dir, main page]

Skip to content

Commit 8ab368d

Browse files
committed
merged branch fabpot/exception-format (PR symfony#8819)
This PR was merged into the 2.2 branch. Discussion ---------- [HttpKernel] Fix request _format duplication for HttpKernel's ExceptionListener | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | symfony#8777, symfony#8778 | License | MIT This is a better fix for symfony#8777. Commits ------- f946108 fixed the format of the request used to render an exception
2 parents b72bc0b + f946108 commit 8ab368d

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

UPGRADE-3.0.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@ UPGRADE FROM 2.x to 3.0
3434
* `Symfony\Bridge\Monolog\Logger`
3535
* `Symfony\Component\HttpKernel\Log\NullLogger`
3636

37+
* The `Symfony\Component\HttpKernel\EventListener\ExceptionListener` now
38+
passes the Request format as the `_format` argument instead of `format`.
39+
3740
### Routing
3841

3942
* Some route settings have been renamed:

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,20 @@ public function __construct(\Twig_Environment $twig, $debug)
3939
* @param Request $request The request
4040
* @param FlattenException $exception A FlattenException instance
4141
* @param DebugLoggerInterface $logger A DebugLoggerInterface instance
42-
* @param string $format The format to use for rendering (html, xml, ...)
42+
* @param string $_format The format to use for rendering (html, xml, ...)
4343
*
4444
* @return Response
4545
*
4646
* @throws \InvalidArgumentException When the exception template does not exist
4747
*/
48-
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $format = 'html')
48+
public function showAction(Request $request, FlattenException $exception, DebugLoggerInterface $logger = null, $_format = 'html')
4949
{
50-
$request->setRequestFormat($format);
51-
5250
$currentContent = $this->getAndCleanOutputBuffering($request->headers->get('X-Php-Ob-Level', -1));
5351

5452
$code = $exception->getStatusCode();
5553

5654
return new Response($this->twig->render(
57-
$this->findTemplate($request, $format, $code, $this->debug),
55+
$this->findTemplate($request, $_format, $code, $this->debug),
5856
array(
5957
'status_code' => $code,
6058
'status_text' => isset(Response::$statusTexts[$code]) ? Response::$statusTexts[$code] : '',

src/Symfony/Component/HttpKernel/EventListener/ExceptionListener.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function onKernelException(GetResponseForExceptionEvent $event)
5555
'_controller' => $this->controller,
5656
'exception' => FlattenException::create($exception),
5757
'logger' => $this->logger instanceof DebugLoggerInterface ? $this->logger : null,
58+
'_format' => $request->getRequestFormat(),
59+
// keep for BC -- as $format can be an argument of the controller callable
60+
// see src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php
61+
// @deprecated in 2.4, to be removed in 3.0
5862
'format' => $request->getRequestFormat(),
5963
);
6064

0 commit comments

Comments
 (0)
0