From 6e97a8a3939a331df276b5840836d1dac5ded5b8 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Tue, 11 May 2010 16:24:24 +0000 Subject: [PATCH] - bugfix make sure that the cache resource is loaded in all conditions when template methods getCached... are called externally --- change_log.txt | 3 +++ libs/sysplugins/smarty_internal_template.php | 11 ++++++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/change_log.txt b/change_log.txt index 133a5b81..5635ff05 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +11/05/2010 +- bugfix make sure that the cache resource is loaded in all conditions when template methods getCached... are called externally + 10/05/2010 - bugfix on {foreach} and {for} optimizations of 27/04/2010 diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 3dfd3f31..e82b49a9 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -271,7 +271,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { touch($this->getCompiledFilepath(), $saved_timestamp); } throw $e; - } + } // compiling succeded if (!$this->resource_object->isEvaluated) { // write compiled template @@ -291,6 +291,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { */ public function getCachedFilepath () { + if (!isset($this->cache_resource_object)) { + $this->cache_resource_object = $this->smarty->cache->loadResource(); + } return $this->cached_filepath === null ? $this->cached_filepath = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedFilepath($this) : $this->cached_filepath; @@ -305,6 +308,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { */ public function getCachedTimestamp () { + if (!isset($this->cache_resource_object)) { + $this->cache_resource_object = $this->smarty->cache->loadResource(); + } return $this->cached_timestamp === null ? $this->cached_timestamp = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedTimestamp($this) : $this->cached_timestamp; @@ -317,6 +323,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { */ public function getCachedContent () { + if (!isset($this->cache_resource_object)) { + $this->cache_resource_object = $this->smarty->cache->loadResource(); + } return $this->rendered_content === null ? $this->rendered_content = ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) ? false : $this->cache_resource_object->getCachedContents($this) : $this->rendered_content;