mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00: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:
parent
e10d62badc
commit
5afc0b9b90
4 changed files with 29 additions and 4 deletions
|
@ -520,7 +520,11 @@ class phpbb_template_filter extends php_user_filter
|
||||||
if (!empty($varrefs[1]))
|
if (!empty($varrefs[1]))
|
||||||
{
|
{
|
||||||
$namespace = substr($varrefs[1], 0, -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
|
// 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
|
// 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(),
|
||||||
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
array('outer' => array(array('VARIABLE' => 'x'), array('VARIABLE' => 'y')), 'outer.inner' => array(array('VARIABLE' => 'z'), array('VARIABLE' => 'zz'))),
|
||||||
array(),
|
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
|
top-level content
|
||||||
<!-- BEGIN outer -->
|
<!-- BEGIN outer -->
|
||||||
outer content
|
outer {outer.VARIABLE}
|
||||||
<!-- BEGIN inner -->
|
<!-- BEGIN inner -->
|
||||||
inner content
|
inner {inner.VARIABLE}
|
||||||
<!-- IF outer.inner.S_FIRST_ROW -->
|
<!-- IF outer.inner.S_FIRST_ROW -->
|
||||||
first row
|
first row
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
|
Loading…
Add table
Reference in a new issue