From d8b26c5ad087cfe64cd9e233e2a23cf5d6b6dc9a Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Fri, 20 Jan 2012 18:21:32 +0000 Subject: [PATCH] - bugfix output filter must not run before writing cache when template does contain nocache code {Issue 71} --- change_log.txt | 1 + .../smarty_internal_templatebase.php | 24 +++++++++---------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/change_log.txt b/change_log.txt index d9ed3c45..51417253 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - bugfix typo in Smarty_Internal_Get_IncludePath did cause runtime overhead (Issue 74) - improvment remove unneeded assigments (Issue 75 and 76) - fixed typo in template parser +- bugfix output filter must not run before writing cache when template does contain nocache code {Issue 71} 02.01.2012 - bugfix {block foo nocache} did not load plugins within child {block} in nocache mode (Forum Topic 20753) diff --git a/libs/sysplugins/smarty_internal_templatebase.php b/libs/sysplugins/smarty_internal_templatebase.php index 83209d26..b6abc002 100644 --- a/libs/sysplugins/smarty_internal_templatebase.php +++ b/libs/sysplugins/smarty_internal_templatebase.php @@ -242,7 +242,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { $output .= preg_replace("!/\*/?%%SmartyNocache:{$_template->properties['nocache_hash']}%%\*/!", '', $cache_parts[0][$curr_idx]); } } - if (!$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + if (!$no_output_filter && !$_template->has_nocache_code && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { $output = Smarty_Internal_Filter_Handler::runFilter('output', $output, $_template); } // rendering (must be done before writing cache file because of {function} nocache handling) @@ -293,7 +293,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { Smarty_Internal_Debug::end_cache($_template); } } - if ((!$this->caching || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { + if ((!$this->caching || $_template->has_nocache_code || $_template->source->recompiled) && !$no_output_filter && (isset($this->smarty->autoload_filters['output']) || isset($this->smarty->registered_filters['output']))) { $_output = Smarty_Internal_Filter_Handler::runFilter('output', $_output, $_template); } if (isset($this->error_reporting)) { @@ -429,7 +429,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { } else { $this->smarty->registered_plugins[$type][$tag] = array($callback, (bool) $cacheable, (array) $cache_attr); } - + return $this; } @@ -445,7 +445,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_plugins[$type][$tag])) { unset($this->smarty->registered_plugins[$type][$tag]); } - + return $this; } @@ -473,7 +473,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_resources[$type])) { unset($this->smarty->registered_resources[$type]); } - + return $this; } @@ -501,7 +501,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_cache_resources[$type])) { unset($this->smarty->registered_cache_resources[$type]); } - + return $this; } @@ -570,7 +570,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_objects[$name])) { unset($this->smarty->registered_objects[$name]); } - + return $this; } @@ -607,7 +607,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { } else { throw new SmartyException("Default plugin handler '$callback' not callable"); } - + return $this; } @@ -625,7 +625,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { } else { throw new SmartyException("Default template handler '$callback' not callable"); } - + return $this; } @@ -643,7 +643,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { } else { throw new SmartyException("Default config handler '$callback' not callable"); } - + return $this; } @@ -673,7 +673,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_filters[$type][$name])) { unset($this->smarty->registered_filters[$type][$name]); } - + return $this; } @@ -730,7 +730,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data { if (isset($this->smarty->registered_filters[$type][$_filter_name])) { unset ($this->smarty->registered_filters[$type][$_filter_name]); } - + return $this; }