- bugfix {if} and {while} tags without condition did not throw a SmartyCompilerException (Issue #57)

This commit is contained in:
uwe.tews@googlemail.com
2011-11-01 20:27:53 +00:00
parent 4f4cb7847d
commit d3e71dabb6
3 changed files with 73 additions and 57 deletions

View File

@@ -1,4 +1,7 @@
===== trunk ===== ===== trunk =====
01.11.2011
- bugfix {if} and {while} tags without condition did not throw a SmartyCompilerException (Issue #57)
22.10.2011 22.10.2011
- bugfix smarty_mb_from_unicode() would not decode unicode-points properly - bugfix smarty_mb_from_unicode() would not decode unicode-points properly
- bugfix use catch Exception instead UnexpectedValueException in - bugfix use catch Exception instead UnexpectedValueException in

View File

@@ -1,20 +1,20 @@
<?php <?php
/** /**
* Smarty Internal Plugin Compile If * Smarty Internal Plugin Compile If
* *
* Compiles the {if} {else} {elseif} {/if} tags * Compiles the {if} {else} {elseif} {/if} tags
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
* @author Uwe Tews * @author Uwe Tews
*/ */
/** /**
* Smarty Internal Plugin Compile If Class * Smarty Internal Plugin Compile If Class
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
/** /**
@@ -32,6 +32,11 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
$this->openTag($compiler, 'if', array(1, $compiler->nocache)); $this->openTag($compiler, 'if', array(1, $compiler->nocache));
// must whole block be nocache ? // must whole block be nocache ?
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
if (!array_key_exists("if condition",$parameter)) {
$compiler->trigger_template_error("missing if condition", $compiler->lex->taglineno);
}
if (is_array($parameter['if condition'])) { if (is_array($parameter['if condition'])) {
if ($compiler->nocache) { if ($compiler->nocache) {
$_nocache = ',true'; $_nocache = ',true';
@@ -60,11 +65,11 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase {
} }
/** /**
* Smarty Internal Plugin Compile Else Class * Smarty Internal Plugin Compile Else Class
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
/** /**
@@ -86,11 +91,11 @@ class Smarty_Internal_Compile_Else extends Smarty_Internal_CompileBase {
} }
/** /**
* Smarty Internal Plugin Compile ElseIf Class * Smarty Internal Plugin Compile ElseIf Class
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
/** /**
@@ -108,6 +113,10 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif')); list($nesting, $compiler->tag_nocache) = $this->closeTag($compiler, array('if', 'elseif'));
if (!array_key_exists("if condition",$parameter)) {
$compiler->trigger_template_error("missing elseif condition", $compiler->lex->taglineno);
}
if (is_array($parameter['if condition'])) { if (is_array($parameter['if condition'])) {
$condition_by_assign = true; $condition_by_assign = true;
if ($compiler->nocache) { if ($compiler->nocache) {
@@ -164,11 +173,11 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase {
} }
/** /**
* Smarty Internal Plugin Compile Ifclose Class * Smarty Internal Plugin Compile Ifclose Class
* *
* @package Smarty * @package Smarty
* @subpackage Compiler * @subpackage Compiler
*/ */
class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase { class Smarty_Internal_Compile_Ifclose extends Smarty_Internal_CompileBase {
/** /**

View File

@@ -31,6 +31,10 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase {
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
$this->openTag($compiler, 'while', $compiler->nocache); $this->openTag($compiler, 'while', $compiler->nocache);
if (!array_key_exists("if condition",$parameter)) {
$compiler->trigger_template_error("missing while condition", $compiler->lex->taglineno);
}
// maybe nocache because of nocache variables // maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
if (is_array($parameter['if condition'])) { if (is_array($parameter['if condition'])) {