From 319f0c88fbdd2bc976417515c4f0ca2b1755d506 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Mon, 30 Nov 2009 17:52:13 +0000 Subject: [PATCH] - map 'true' to SMARTY_CACHING_LIFETIME_CURRENT for the $smarty->caching parameter --- change_log.txt | 3 +++ libs/Smarty.class.php | 2 +- libs/sysplugins/smarty_internal_template.php | 13 +++++++------ 3 files changed, 11 insertions(+), 7 deletions(-) diff --git a/change_log.txt b/change_log.txt index cf87e65b..215c3f07 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +11/30/2009 +- map 'true' to SMARTY_CACHING_LIFETIME_CURRENT for the $smarty->caching parameter + 11/28/2009 - ignore compile_id at debug template - added direct access to constants in templates diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 3a755235..a3a360c6 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -418,7 +418,7 @@ class Smarty extends Smarty_Internal_TemplateBase { */ public function enableCaching() { - $this->caching = true; + $this->caching = SMARTY_CACHING_LIFETIME_CURRENT; return; } /** diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index a649c78b..fae84a0a 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -84,6 +84,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { $this->compile_id = $_compile_id === null ? $this->smarty->compile_id : $_compile_id; $this->force_compile = $this->smarty->force_compile; $this->caching = $_caching === null ? $this->smarty->caching : $_caching; + if ($this->caching === true) $this->caching = SMARTY_CACHING_LIFETIME_CURRENT; $this->cache_lifetime = $_cache_lifetime === null ?$this->smarty->cache_lifetime : $_cache_lifetime; $this->force_cache = $this->smarty->force_cache; $this->cacher_class = $this->smarty->cacher_class; @@ -99,7 +100,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { throw new Exception ("Unable to parse resource name \"{$template_resource}\""); } // load cache resource - if (!$this->isEvaluated() && $this->caching) { + if (!$this->isEvaluated() && ($this->caching == 1 || $this->caching == 2)) { $this->cache_resource_object = $this->smarty->loadCacheResource(); } } @@ -318,7 +319,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { public function getCachedFilepath () { return $this->cached_filepath === null ? - $this->cached_filepath = ($this->isEvaluated() || !$this->caching) ? false : $this->cache_resource_object->getCachedFilepath($this) : + $this->cached_filepath = ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedFilepath($this) : $this->cached_filepath; } @@ -332,7 +333,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { public function getCachedTimestamp () { return $this->cached_timestamp === null ? - $this->cached_timestamp = ($this->isEvaluated() || !$this->caching) ? false : $this->cache_resource_object->getCachedTimestamp($this) : + $this->cached_timestamp = ($this->isEvaluated() || !($this->caching ==1 || $this->caching ==2)) ? false : $this->cache_resource_object->getCachedTimestamp($this) : $this->cached_timestamp; } @@ -344,7 +345,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { public function getCachedContent () { return $this->rendered_content === null ? - $this->rendered_content = ($this->isEvaluated() || !$this->caching) ? false : $this->cache_resource_object->getCachedContents($this) : + $this->rendered_content = ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedContents($this) : $this->rendered_content; } @@ -355,7 +356,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { { // build file dependency string $this->properties['cache_lifetime'] = $this->cache_lifetime; - return ($this->isEvaluated() || !$this->caching) ? false : $this->cache_resource_object->writeCachedContent($this, $this->createPropertyHeader() . $this->rendered_content); + return ($this->isEvaluated() || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->writeCachedContent($this, $this->createPropertyHeader() . $this->rendered_content); } /** @@ -369,7 +370,7 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { { if ($this->isCached === null) { $this->isCached = false; - if ($this->caching && !$this->isEvaluated() && !$this->force_compile && !$this->force_cache) { + if (($this->caching == 1 || $this->caching == 2) && !$this->isEvaluated() && !$this->force_compile && !$this->force_cache) { if ($this->getCachedTimestamp() === false) { return $this->isCached; }