- bugfix compiler did overwrite existing variable value when setting the nocache attribute https://github.com/smarty-php/smarty/issues/39

This commit is contained in:
Uwe Tews
2015-05-19 22:47:04 +02:00
parent dcf53ca957
commit 5468f140fa
4 changed files with 30 additions and 7 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.24.dev ===== (xx.xx.2015)  ===== 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 18.05.2015
- improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher - improvement introduce shortcuts in lexer/parser rules for most frequent terms for higher
compilation speed compilation speed

View File

@@ -42,9 +42,14 @@ class Smarty_Internal_Compile_If extends Smarty_Internal_CompileBase
$_nocache = ',true'; $_nocache = ',true';
// create nocache var to make it know for further compiling // create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) { 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 { } 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 { } else {
$_nocache = ''; $_nocache = '';
@@ -124,9 +129,14 @@ class Smarty_Internal_Compile_Elseif extends Smarty_Internal_CompileBase
$_nocache = ',true'; $_nocache = ',true';
// create nocache var to make it know for further compiling // create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) { 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 { } 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 { } else {
$_nocache = ''; $_nocache = '';

View File

@@ -68,7 +68,12 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
// output will be stored in a smarty variable instead of being displayed // output will be stored in a smarty variable instead of being displayed
$_assign = $_attr['assign']; $_assign = $_attr['assign'];
// create variable to make sure that the compiler knows about its nocache status // 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'])) { if (isset($_attr['script'])) {
// script which must be included // script which must be included

View File

@@ -42,9 +42,14 @@ class Smarty_Internal_Compile_While extends Smarty_Internal_CompileBase
$_nocache = ',true'; $_nocache = ',true';
// create nocache var to make it know for further compiling // create nocache var to make it know for further compiling
if (is_array($parameter['if condition']['var'])) { 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 { } 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 { } else {
$_nocache = ''; $_nocache = '';