From e8fbee624da342b1ff292942a9d2b277dcfb9f44 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Sat, 31 Jul 2010 13:29:59 +0000 Subject: [PATCH] - bugfix on nocache attribute at {assign} and {append} --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_compile_append.php | 10 ++++++++-- libs/sysplugins/smarty_internal_compile_assign.php | 12 +++++++++--- libs/sysplugins/smarty_internal_template.php | 4 +++- 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/change_log.txt b/change_log.txt index 24f09fe7..88858817 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +31/07/2010 +- bugfix on nocache attribute at {assign} and {append} + 30/07/2010 - bugfix passing scope attributes in doublequoted strings did not work at {include} {assign} and {append} diff --git a/libs/sysplugins/smarty_internal_compile_append.php b/libs/sysplugins/smarty_internal_compile_append.php index 48eda0cb..5f207626 100644 --- a/libs/sysplugins/smarty_internal_compile_append.php +++ b/libs/sysplugins/smarty_internal_compile_append.php @@ -32,14 +32,20 @@ class Smarty_Internal_Compile_Append extends Smarty_Internal_CompileBase { // it shall not controll caching of the compiled code, but is a parameter if (isset($args['nocache'])) { if ($args['nocache'] == 'true') { - $_nocache = 'true'; - $_nocache_boolean = true; + $this->compiler->tag_nocache = true; } unset($args['nocache']); } + // check and get attributes $_attr = $this->_get_attributes($args); + if ($this->compiler->tag_nocache) { + $_nocache = 'true'; + // create nocache var to make it know for further compiling + $compiler->template->tpl_vars[trim($_attr['var'],"'")] = new Smarty_variable(null, true); + } + if (isset($_attr['scope'])) { $_attr['scope'] = trim($_attr['scope'], "'\""); if ($_attr['scope'] == 'parent') { diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index 29881e87..4f3159fa 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -24,7 +24,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { { $this->compiler = $compiler; $this->required_attributes = array('var', 'value'); - $this->optional_attributes = array('scope', 'nocache', 'smarty_internal_index'); + $this->optional_attributes = array('scope', 'nocache', 'smarty_internal_index'); $_nocache = 'null'; $_scope = 'null'; @@ -32,14 +32,20 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { // it shall not controll caching of the compiled code, but is a parameter if (isset($args['nocache'])) { if ($args['nocache'] == 'true') { - $_nocache = 'true'; - $_nocache_boolean = true; + $this->compiler->tag_nocache = true; } unset($args['nocache']); } + // check and get attributes $_attr = $this->_get_attributes($args); + if ($this->compiler->tag_nocache) { + $_nocache = 'true'; + // create nocache var to make it know for further compiling + $compiler->template->tpl_vars[trim($_attr['var'],"'")] = new Smarty_variable(null, true); + } + if (isset($_attr['scope'])) { $_attr['scope'] = trim($_attr['scope'], "'\""); if ($_attr['scope'] == 'parent') { diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index bef14c57..d35aafbf 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -375,7 +375,8 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { } $this->cacheFileChecked = true; if ($this->caching === SMARTY_CACHING_LIFETIME_SAVED && $this->properties['cache_lifetime'] >= 0 && (time() > ($this->getCachedTimestamp() + $this->properties['cache_lifetime']))) { - $this->rendered_content = null; + $this->tpl_vars = array(); + $this->rendered_content = null; return $this->isCached; } if (!empty($this->properties['file_dependency']) && $this->smarty->compile_check) { @@ -389,6 +390,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { } // If ($mtime > $this->getCachedTimestamp()) { If ($mtime > $_file_to_check[1]) { + $this->tpl_vars = array(); $this->rendered_content = null; return $this->isCached; }