8000 bug #21179 [TwigBundle] Fixing regression in TwigEngine exception han… · symfony/symfony@f03073c · GitHub
[go: up one dir, main page]

Skip to content

Commit f03073c

Browse files
bug #21179 [TwigBundle] Fixing regression in TwigEngine exception handling (Bertalan Attila)
This PR was merged into the 2.7 branch. Discussion ---------- [TwigBundle] Fixing regression in TwigEngine exception handling | Q | A | ------------- | --- | Branch? | 2.7 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #21176 | License | MIT Fixing regression after #20831 in TwigEngine exception handling. Commits ------- 390cb33 Fixing regression in TwigEngine exception handling.
2 parents d18c2ca + 390cb33 commit f03073c

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

src/Symfony/Bundle/TwigBundle/TwigEngine.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,12 @@ public function render($name, array $parameters = array())
7171
try {
7272
return parent::render($name, $parameters);
7373
} catch (\Twig_Error $e) {
74-
if ($name instanceof TemplateReference) {
74+
if ($name instanceof TemplateReference && !method_exists($e, 'setSourceContext')) {
7575
try {
7676
// try to get the real name of the template where the error occurred
7777
$name = $e->getTemplateName();
7878
$path = (string) $this->locator->locate($this->parser->parse($name));
79-
if (method_exists($e, 'setSourceContext')) {
80-
$e->setSourceContext(new \Twig_Source('', $name, $path));
81-
} else {
82-
$e->setTemplateName($path);
83-
}
79+
$e->setTemplateName($path);
8480
} catch (\Exception $e2) {
8581
}
8682
}

0 commit comments

Comments
 (0)
0