mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-06 11:24:27 +02:00
- update cached_timestamp at the template object after cache file is written to avoid possible side effects
- use internally always SMARTY_CACHING_LIFETIME_* constants
This commit is contained in:
@@ -1,3 +1,7 @@
|
|||||||
|
01/02/2009
|
||||||
|
- update cached_timestamp at the template object after cache file is written to avoid possible side effects
|
||||||
|
- use internally always SMARTY_CACHING_LIFETIME_* constants
|
||||||
|
|
||||||
01/01/2009
|
01/01/2009
|
||||||
- bugfix for obtaining plugins which must be included (related to change of 12/30/2009)
|
- bugfix for obtaining plugins which must be included (related to change of 12/30/2009)
|
||||||
- bugfix for {php} tag (trow an exception if allow_php_tag = false)
|
- bugfix for {php} tag (trow an exception if allow_php_tag = false)
|
||||||
|
@@ -65,11 +65,13 @@ class Smarty_Internal_CacheResource_File {
|
|||||||
public function writeCachedContent($template, $content)
|
public function writeCachedContent($template, $content)
|
||||||
{
|
{
|
||||||
if (!$template->resource_object->isEvaluated) {
|
if (!$template->resource_object->isEvaluated) {
|
||||||
return Smarty_Internal_Write_File::writeFile($template->getCachedFilepath(), $content, $this->smarty);
|
if (Smarty_Internal_Write_File::writeFile($template->getCachedFilepath(), $content, $this->smarty) === true) {
|
||||||
} else {
|
$template->cached_timestamp = filemtime($template->getCachedFilepath());
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Empty cache folder
|
* Empty cache folder
|
||||||
|
@@ -50,7 +50,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
public $rendered_content = null;
|
public $rendered_content = null;
|
||||||
// Cache file
|
// Cache file
|
||||||
private $cached_filepath = null;
|
private $cached_filepath = null;
|
||||||
private $cached_timestamp = null;
|
public $cached_timestamp = null;
|
||||||
private $isCached = null;
|
private $isCached = null;
|
||||||
private $cache_resource_object = null;
|
private $cache_resource_object = null;
|
||||||
private $cacheFileWritten = false;
|
private $cacheFileWritten = false;
|
||||||
@@ -103,7 +103,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
throw new Exception ("Unable to parse resource name \"{$template_resource}\"");
|
throw new Exception ("Unable to parse resource name \"{$template_resource}\"");
|
||||||
}
|
}
|
||||||
// load cache resource
|
// load cache resource
|
||||||
if (!$this->resource_object->isEvaluated && ($this->caching == 1 || $this->caching == 2)) {
|
if (!$this->resource_object->isEvaluated && ($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) {
|
||||||
$this->cache_resource_object = $this->smarty->loadCacheResource();
|
$this->cache_resource_object = $this->smarty->loadCacheResource();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
public function getCachedFilepath ()
|
public function getCachedFilepath ()
|
||||||
{
|
{
|
||||||
return $this->cached_filepath === null ?
|
return $this->cached_filepath === null ?
|
||||||
$this->cached_filepath = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedFilepath($this) :
|
$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;
|
$this->cached_filepath;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,7 +305,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
public function getCachedTimestamp ()
|
public function getCachedTimestamp ()
|
||||||
{
|
{
|
||||||
return $this->cached_timestamp === null ?
|
return $this->cached_timestamp === null ?
|
||||||
$this->cached_timestamp = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedTimestamp($this) :
|
$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;
|
$this->cached_timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +317,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
public function getCachedContent ()
|
public function getCachedContent ()
|
||||||
{
|
{
|
||||||
return $this->rendered_content === null ?
|
return $this->rendered_content === null ?
|
||||||
$this->rendered_content = ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) ? false : $this->cache_resource_object->getCachedContents($this) :
|
$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;
|
$this->rendered_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -326,7 +326,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
*/
|
*/
|
||||||
public function writeCachedContent ()
|
public function writeCachedContent ()
|
||||||
{
|
{
|
||||||
if ($this->resource_object->isEvaluated || !($this->caching == 1 || $this->caching == 2)) {
|
if ($this->resource_object->isEvaluated || !($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED)) {
|
||||||
// don't write cache file
|
// don't write cache file
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -361,7 +361,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data {
|
|||||||
{
|
{
|
||||||
if ($this->isCached === null) {
|
if ($this->isCached === null) {
|
||||||
$this->isCached = false;
|
$this->isCached = false;
|
||||||
if (($this->caching == 1 || $this->caching == 2) && !$this->resource_object->isEvaluated && !$this->force_compile && !$this->force_cache) {
|
if (($this->caching == SMARTY_CACHING_LIFETIME_CURRENT || $this->caching == SMARTY_CACHING_LIFETIME_SAVED) && !$this->resource_object->isEvaluated && !$this->force_compile && !$this->force_cache) {
|
||||||
$cachedTimestamp = $this->getCachedTimestamp();
|
$cachedTimestamp = $this->getCachedTimestamp();
|
||||||
if ($cachedTimestamp === false) {
|
if ($cachedTimestamp === false) {
|
||||||
return $this->isCached;
|
return $this->isCached;
|
||||||
|
Reference in New Issue
Block a user