Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73e9348

Browse files
committed
bug #23283 [TwigBundle] add back exception check (xabbuh)
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] add back exception check | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23268 | License | MIT | Doc PR | #23268 introduced a regression in that the full exception page was not shown anymore in case a template for the given format (if not `html`) could not be found. Commits ------- 46c38df [TwigBundle] add back exception check
2 parents 9fc9cc4 + 46c38df commit 73e9348

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected function findTemplate(Request $request, $format, $code, $showException
125125
// default to a generic HTML exception
126126
$request->setRequestFormat('html');
127127

128-
return new TemplateReference('TwigBundle', 'Exception', $name, 'html', 'twig');
128+
return new TemplateReference('TwigBundle', 'Exception', $showException ? 'exception_full' : $name, 'html', 'twig');
129129
}
130130

131131
// to be removed when the minimum required version of Twig is >= 3.0

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ public function testFallbackToHtmlIfNoTemplateForRequestedFormat()
4848
$this->assertEquals('html', $request->getRequestFormat());
4949
}
5050

51+
public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown()
52+
{
53+
$twig = $this->createTwigEnv(array('TwigBundle:Exception:exception_full.html.twig' => '<html></html>'));
54+
55+
$request = $this->createRequest('txt');
56+
$request->attributes->set('showException', true);
57+
$exception = FlattenException::create(new \Exception());
58+
$controller = new ExceptionController($twig, false);
59+
60+
$controller->showAction($request, $exception);
61+
62+
$this->assertEquals('html', $request->getRequestFormat());
63+
}
64+
5165
public function testResponseHasRequestedMimeType()
5266
{
5367
$twig = $this->createTwigEnv(array('TwigBundle:Exception:error.json.twig' => '{}'));

0 commit comments

Comments
 (0)