Skip to content

Commit

Permalink
- bugfix compiler did overwrite existing variable value when setting …
Browse files Browse the repository at this point in the history
…the nocache attribute #39
  • Loading branch information
uwetews committed May 19, 2015
1 parent dcf53ca commit 5468f14
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 7 deletions.
3 changes: 3 additions & 0 deletions change_log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
 ===== 3.1.24.dev ===== (xx.xx.2015)
19.05.2015
- bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39

18.05.2015
- improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher
compilation speed
Expand Down
18 changes: 14 additions & 4 deletions libs/sysplugins/smarty_internal_compile_if.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ public function compile($args, $compiler, $parameter)
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
$var = trim($parameter['if condition']['var']['var'], "'");
} else {
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
$var = trim($parameter['if condition']['var'], "'");
}
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
}
} else {
$_nocache = '';
Expand Down Expand Up @@ -124,9 +129,14 @@ public function compile($args, $compiler, $parameter)
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
$var = trim($parameter['if condition']['var']['var'], "'");
} else {
$var = trim($parameter['if condition']['var'], "'");
}
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
}
} else {
$_nocache = '';
Expand Down
7 changes: 6 additions & 1 deletion libs/sysplugins/smarty_internal_compile_insert.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ public function compile($args, $compiler)
// output will be stored in a smarty variable instead of being displayed
$_assign = $_attr['assign'];
// create variable to make sure that the compiler knows about its nocache status
$compiler->template->tpl_vars[trim($_attr['assign'], "'")] = new Smarty_Variable(null, true);
$var = trim($_attr['assign'], "'");
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
}
}
if (isset($_attr['script'])) {
// script which must be included
Expand Down
9 changes: 7 additions & 2 deletions libs/sysplugins/smarty_internal_compile_while.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@ public function compile($args, $compiler, $parameter)
$_nocache = ',true';
// create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) {
$compiler->template->tpl_vars[trim($parameter['if condition']['var']['var'], "'")] = new Smarty_Variable(null, true);
$var = trim($parameter['if condition']['var']['var'], "'");
} else {
$compiler->template->tpl_vars[trim($parameter['if condition']['var'], "'")] = new Smarty_Variable(null, true);
$var = trim($parameter['if condition']['var'], "'");
}
if (isset($compiler->template->tpl_vars[$var])) {
$compiler->template->tpl_vars[$var]->nocache = true;
} else {
$compiler->template->tpl_vars[$var] = new Smarty_Variable(null, true);
}
} else {
$_nocache = '';
Expand Down

0 comments on commit 5468f14

Please sign in to comment.