From: Fabien Potencier Date: Mon, 12 Jul 2010 15:48:10 +0000 (+0200) Subject: fixed template cloning problem with inheritance X-Git-Url: http://git.silmor.de/gitweb/?a=commitdiff_plain;h=277c4430c6ca8ee96d4d53391a804cdf3f8dab0a;p=web%2Fkonrad%2Ftwig.git fixed template cloning problem with inheritance --- diff --git a/lib/Twig/Node/Module.php b/lib/Twig/Node/Module.php index 7ffa28c..add0e31 100644 --- a/lib/Twig/Node/Module.php +++ b/lib/Twig/Node/Module.php @@ -78,15 +78,16 @@ class Twig_Node_Module extends Twig_Node ; } else { $compiler - ->write("\$this->parent = ") + ->write("\$parent = ") ->subcompile($this->parent) ->raw(";\n") - ->write("if (!\$this->parent") + ->write("if (!\$parent") ->raw(" instanceof Twig_Template) {\n") ->indent() - ->write("\$this->parent = clone \$this->env->loadTemplate(\$this->parent);\n") + ->write("\$parent = \$this->env->loadTemplate(\$parent);\n") ->outdent() ->write("}\n") + ->write("\$this->parent = clone \$parent;\n") ; } diff --git a/test/Twig/Tests/Node/ModuleTest.php b/test/Twig/Tests/Node/ModuleTest.php index be6d8d8..37a891e 100644 --- a/test/Twig/Tests/Node/ModuleTest.php +++ b/test/Twig/Tests/Node/ModuleTest.php @@ -124,10 +124,11 @@ class __TwigTemplate_be925a7b06dda0dfdbd18a1509f7eb34 extends Twig_Template public function display(array \$context) { if (null === \$this->parent) { - \$this->parent = (true) ? ("foo") : ("foo"); - if (!\$this->parent instanceof Twig_Template) { - \$this->parent = clone \$this->env->loadTemplate(\$this->parent); + \$parent = (true) ? ("foo") : ("foo"); + if (!\$parent instanceof Twig_Template) { + \$parent = \$this->env->loadTemplate(\$parent); } + \$this->parent = clone \$parent; \$this->parent->pushBlocks(\$this->blocks); } \$this->parent->display(\$context);