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

Skip to content

Commit b2ec4aa

Browse files
committed
bug #28005 [HttpKernel] Fixed templateExists on parse error of the template name (yceruto)
This PR was merged into the 2.8 branch. Discussion ---------- [HttpKernel] Fixed templateExists on parse error of the template name | Q | A | ------------- | --- | Branch? | 2.8 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #28001 | License | MIT | Doc PR | - https://github.com/symfony/symfony/blob/9bfa971bc5662a6f90408b58a7b2453d7dae4f83/src/Symfony/Bundle/FrameworkBundle/Templating/TemplateNameParser.php#L49-L51 Commits ------- 53347c4 Fixed templateExists on parse error of the template name
2 parents 48644a8 + 53347c4 commit b2ec4aa

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Symfony/Component/HttpKernel/Fragment/HIncludeFragmentRenderer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ private function templateExists($template)
135135
if ($this->templating instanceof EngineInterface) {
136136
try {
137137
return $this->templating->exists($template);
138-
} catch (\InvalidArgumentException $e) {
138+
} catch (\Exception $e) {
139139
return false;
140140
}
141141
}

src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,4 +86,17 @@ public function testRenderWithDefaultText()
8686
$strategy = new HIncludeFragmentRenderer($engine);
8787
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
8888
}
89+
90+
public function testRenderWithEngineAndDefaultText()
91+
{
92+
$engine = $this->getMockBuilder('Symfony\\Component\\Templating\\EngineInterface')->getMock();
93+
$engine->expects($this->once())
94+
->method('exists')
95+
->with('loading...')
96+
->will($this->throwException(new \RuntimeException()));
97+
98+
// only default
99+
$strategy = new HIncludeFragmentRenderer($engine);
100+
$this->assertEquals('<hx:include src="/foo">loading...</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'loading...'))->getContent());
101+
}
89102
}

0 commit comments

Comments
 (0)