mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-27 21:58:52 +00:00
[feature/template-engine] Corrected miscompilation of loop size constructs.
PHPBB3-9726
This commit is contained in:
parent
8d5e468eb4
commit
f97411b911
3 changed files with 47 additions and 1 deletions
|
@ -588,7 +588,7 @@ class phpbb_template_filter extends php_user_filter
|
|||
// Add the block reference for the last child.
|
||||
$varref .= "['" . $blocks[0] . "']";
|
||||
}
|
||||
$token = "isset($varref) && sizeof($varref)";
|
||||
$token = "(isset($varref) ? sizeof($varref) : 0)";
|
||||
}
|
||||
|
||||
break;
|
||||
|
|
|
@ -288,6 +288,13 @@ class phpbb_template_template_test extends phpbb_test_case
|
|||
// I don't completely understand this output, hopefully it's correct
|
||||
"top-level content\nouter\n\ninner z\nfirst row\n\ninner zz",
|
||||
),
|
||||
array(
|
||||
'loop_size.html',
|
||||
array(),
|
||||
array('loop' => array(array()), 'empty_loop' => array()),
|
||||
array(),
|
||||
"nonexistent = 0\n! nonexistent\n\nempty = 0\n! empty\nloop\n\nin loop",
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
39
tests/template/templates/loop_size.html
Normal file
39
tests/template/templates/loop_size.html
Normal file
|
@ -0,0 +1,39 @@
|
|||
<!-- IF .nonexistent_loop -->
|
||||
nonexistent
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF .nonexistent_loop == 0 -->
|
||||
nonexistent = 0
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF ! .nonexistent_loop -->
|
||||
! nonexistent
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF .empty_loop -->
|
||||
empty
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF .empty_loop == 0 -->
|
||||
empty = 0
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF ! .empty_loop -->
|
||||
! empty
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF .loop -->
|
||||
loop
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF .loop == 0 -->
|
||||
loop = 0
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- IF ! .loop -->
|
||||
! loop
|
||||
<!-- ENDIF -->
|
||||
|
||||
<!-- BEGIN loop -->
|
||||
in loop
|
||||
<!-- END -->
|
Loading…
Add table
Reference in a new issue