aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpBB/includes/template_compile.php15
-rw-r--r--tests/template/template_test.php2
-rw-r--r--tests/template/templates/basic.html3
-rw-r--r--tests/template/templates/if.html2
4 files changed, 9 insertions, 13 deletions
diff --git a/phpBB/includes/template_compile.php b/phpBB/includes/template_compile.php
index 9a8bc05343..3f8a028e25 100644
--- a/phpBB/includes/template_compile.php
+++ b/phpBB/includes/template_compile.php
@@ -408,7 +408,7 @@ class phpbb_template_filter extends php_user_filter
* some adaptions for our block level methods
* @access private
*/
- private function compile_expression($tag_args, &$vars = array())
+ private function compile_expression($tag_args)
{
$match = array();
preg_match_all('/(?:
@@ -553,14 +553,14 @@ class phpbb_template_filter extends php_user_filter
default:
$token = $this->generate_block_data_ref(substr($varrefs[1], 0, -1), true, $varrefs[2]) . '[\'' . $varrefs[3] . '\']';
- $vars[$token] = true;
+ $token = '(isset(' . $token . ') ? ' . $token . ' : null)';
break;
}
}
else
{
$token = ($varrefs[2]) ? '$_tpldata[\'DEFINE\'][\'.\'][\'' . $varrefs[3] . '\']' : '$_rootref[\'' . $varrefs[3] . '\']';
- $vars[$token] = true;
+ $token = '(isset(' . $token . ') ? ' . $token . ' : null)';
}
}
@@ -601,17 +601,10 @@ class phpbb_template_filter extends php_user_filter
private function compile_tag_if($tag_args, $elseif)
{
- $vars = array();
-
- $tokens = $this->compile_expression($tag_args, $vars);
+ $tokens = $this->compile_expression($tag_args);
$tpl = ($elseif) ? '} else if (' : 'if (';
- if (!empty($vars))
- {
- $tpl .= '(isset(' . implode(') && isset(', array_keys($vars)) . ')) && ';
- }
-
$tpl .= implode(' ', $tokens);
$tpl .= ') { ';
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 4304035192..0a46ff4d23 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -91,7 +91,7 @@ class phpbb_template_template_test extends phpbb_test_case
array(),
array(),
array(),
- "pass\npass\n<!-- DUMMY var -->",
+ "pass\npass\npass\n<!-- DUMMY var -->",
),
array(
'variable.html',
diff --git a/tests/template/templates/basic.html b/tests/template/templates/basic.html
index c1dd690260..e5c6f280fb 100644
--- a/tests/template/templates/basic.html
+++ b/tests/template/templates/basic.html
@@ -16,5 +16,8 @@ fail
<!-- BEGINELSE -->
pass
<!-- END empty -->
+<!-- IF not S_EMPTY -->
+pass
+<!-- ENDIF -->
<!-- DUMMY var -->
diff --git a/tests/template/templates/if.html b/tests/template/templates/if.html
index 41ff024779..eed431019e 100644
--- a/tests/template/templates/if.html
+++ b/tests/template/templates/if.html
@@ -6,6 +6,6 @@
03
<!-- ENDIF -->
-<!-- IF (S_VALUE > S_OTHER_VALUE) -->
+<!-- IF S_VALUE and S_OTHER_VALUE and (S_VALUE > S_OTHER_VALUE) -->
04
<!-- ENDIF -->