mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-01 22:40:39 +02:00
[feature/template-engine] Corrected an off-by-one error in nested namespaces.
This error resulted in a dot from the namespace being placed into variable reference in compiled template code, thus creating bogus compiled template code. PHPBB3-9726
This commit is contained in:
@@ -520,7 +520,11 @@ class phpbb_template_filter extends php_user_filter
|
||||
if (!empty($varrefs[1]))
|
||||
{
|
||||
$namespace = substr($varrefs[1], 0, -1);
|
||||
$namespace = (strpos($namespace, '.') === false) ? $namespace : strrchr($namespace, '.');
|
||||
$dot_pos = strrchr($namespace, '.');
|
||||
if ($dot_pos !== false)
|
||||
{
|
||||
$namespace = substr($dot_pos, 1);
|
||||
}
|
||||
|
||||
// S_ROW_COUNT is deceptive, it returns the current row number not the number of rows
|
||||
// hence S_ROW_COUNT is deprecated in favour of S_ROW_NUM
|
||||
|
@@ -277,7 +277,16 @@ class phpbb_template_template_test extends phpbb_test_case
|
||||
array(),
|
||||
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
||||
array(),
|
||||
"top-level content",
|
||||
// I don't completely understand this output, hopefully it's correct
|
||||
"top-level content\nouter x\nouter y\ninner z\nfirst row\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_nested_deep_multilevel_ref.html',
|
||||
array(),
|
||||
array('outer' => array(array()), 'outer.middle' => array(array()), 'outer.middle.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
||||
array(),
|
||||
// I don't completely understand this output, hopefully it's correct
|
||||
"top-level content\nouter\n\ninner z\nfirst row\n\ninner zz",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
@@ -0,0 +1,12 @@
|
||||
top-level content
|
||||
<!-- BEGIN outer -->
|
||||
outer
|
||||
<!-- BEGIN middle -->
|
||||
<!-- BEGIN inner -->
|
||||
inner {inner.VARIABLE}
|
||||
<!-- IF outer.middle.inner.S_FIRST_ROW -->
|
||||
first row
|
||||
<!-- ENDIF -->
|
||||
<!-- END inner -->
|
||||
<!-- END middle -->
|
||||
<!-- END outer -->
|
@@ -1,8 +1,8 @@
|
||||
top-level content
|
||||
<!-- BEGIN outer -->
|
||||
outer content
|
||||
outer {outer.VARIABLE}
|
||||
<!-- BEGIN inner -->
|
||||
inner content
|
||||
inner {inner.VARIABLE}
|
||||
<!-- IF outer.inner.S_FIRST_ROW -->
|
||||
first row
|
||||
<!-- ENDIF -->
|
||||
|
Reference in New Issue
Block a user