From b92f660ed389414a1d8550a5ba92804f7151eb79 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:08:41 -0500 Subject: [PATCH 1/2] [ticket/11718] Twig lexer only correcting statements in IF, not ELSEIF PHPBB3-11718 --- phpBB/phpbb/template/twig/lexer.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/phpBB/phpbb/template/twig/lexer.php b/phpBB/phpbb/template/twig/lexer.php index 46412ad048..cb44de76f1 100644 --- a/phpBB/phpbb/template/twig/lexer.php +++ b/phpBB/phpbb/template/twig/lexer.php @@ -219,19 +219,20 @@ class phpbb_template_twig_lexer extends Twig_Lexer { $callback = function($matches) { + $inner = $matches[2]; // Replace $TEST with definition.TEST - $matches[1] = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $matches[1]); + $inner = preg_replace('#\s\$([a-zA-Z_0-9]+)#', ' definition.$1', $inner); // Replace .test with test|length - $matches[1] = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $matches[1]); + $inner = preg_replace('#\s\.([a-zA-Z_0-9\.]+)#', ' $1|length', $inner); - return ''; + return ""; }; // Replace our "div by" with Twig's divisibleby (Twig does not like test names with spaces) $code = preg_replace('# div by ([0-9]+)#', ' divisibleby($1)', $code); - return preg_replace_callback('##', $callback, $code); + return preg_replace_callback('##', $callback, $code); } /** From 1c59ad87b026794e44ce6c7561feabd3eb7bf165 Mon Sep 17 00:00:00 2001 From: Nathaniel Guse Date: Fri, 19 Jul 2013 13:34:08 -0500 Subject: [PATCH 2/2] [ticket/11718] Quick test for fixes in ELSEIF PHPBB3-11718 --- tests/template/template_test.php | 2 +- tests/template/templates/define.html | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/template/template_test.php b/tests/template/template_test.php index 802f0c19ba..86af97cc84 100644 --- a/tests/template/template_test.php +++ b/tests/template/template_test.php @@ -151,7 +151,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case array(), array('loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())), array(), - "xyz\nabc\nabc\nbar\nbar\nabc", + "xyz\nabc\n\$VALUE == 'abc'\nabc\nbar\nbar\nabc", ), array( 'define_advanced.html', diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html index 4e6d0ee793..5b8ed9ac40 100644 --- a/tests/template/templates/define.html +++ b/tests/template/templates/define.html @@ -2,6 +2,11 @@ {$VALUE} {$VALUE} + +$VALUE != 'abc' + +$VALUE == 'abc' + {$INCLUDED_VALUE} {$VALUE}