Skip to content

Commit

Permalink
Fix Parser context push on stack
Browse files Browse the repository at this point in the history
  • Loading branch information
molaux authored and fabpot committed Jan 11, 2016
1 parent db93842 commit 07ebdfe
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/Twig/Parser.php
Expand Up @@ -63,7 +63,12 @@ public function getFilename()
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;

Expand Down
5 changes: 4 additions & 1 deletion test/Twig/Tests/Fixtures/tags/embed/with_extends.test
Expand Up @@ -17,6 +17,7 @@
block1extended
{% endblock %}
{% endembed %}
{{ parent() }}
{% endblock %}
--TEMPLATE(base.twig)--
A
Expand Down Expand Up @@ -54,4 +55,6 @@ A
block1extended
B
block2
CB
C blockc2base

B

0 comments on commit 07ebdfe

Please sign in to comment.