Fix Parser context push on stack

This commit is contained in:
Marc-Olivier Laux
2015-12-01 14:59:51 +01:00
committed by Fabien Potencier
parent db93842e80
commit 07ebdfef4d
2 changed files with 10 additions and 2 deletions
+6 -1
View File
@@ -63,7 +63,12 @@ class Twig_Parser implements Twig_ParserInterface
public function parse(Twig_TokenStream $stream, $test = null, $dropNeedle = false)
{
// push all variables into the stack to keep the current state of the parser
$vars = get_object_vars($this);
// using get_object_vars() instead of foreach would lead to https://bugs.php.net/71336
$vars = array();
foreach ($this as $k => $v) {
$vars[$k] = $v;
}
unset($vars['stack'], $vars['env'], $vars['handlers'], $vars['visitors'], $vars['expressionParser'], $vars['reservedMacroNames']);
$this->stack[] = $vars;
@@ -17,6 +17,7 @@
block1extended
{% endblock %}
{% endembed %}
{{ parent() }}
{% endblock %}
--TEMPLATE(base.twig)--
A
@@ -54,4 +55,6 @@ A
block1extended
B
block2
CB
C blockc2base
B