mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +02:00
- bugfix cache lock was not handled correctly after timeout when $cache_locking == true
This commit is contained in:
@@ -139,23 +139,18 @@ class Smarty_Template_Cached
|
|||||||
* Check if cache is valid, lock cache if required
|
* Check if cache is valid, lock cache if required
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $_template
|
* @param \Smarty_Internal_Template $_template
|
||||||
* @param bool $lock keep cache locked
|
|
||||||
*
|
*
|
||||||
* @return bool flag true if cache is valid
|
* @return bool flag true if cache is valid
|
||||||
*/
|
*/
|
||||||
public function isCached(Smarty_Internal_Template $_template, $lock = false)
|
public function isCached(Smarty_Internal_Template $_template)
|
||||||
{
|
{
|
||||||
if ($this->valid === true) {
|
if ($this->valid !== null) {
|
||||||
return true;
|
return $this->valid;
|
||||||
}
|
|
||||||
$force = $_template->smarty->force_compile || $_template->smarty->force_cache;
|
|
||||||
if (!$lock && ($force || !$_template->caching)) {
|
|
||||||
return $this->valid = false;
|
|
||||||
}
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
while (true) {
|
while (true) {
|
||||||
$this->handler->populate($this, $_template);
|
$this->handler->populate($this, $_template);
|
||||||
if ($this->timestamp === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
|
if ($this->exists === false || $_template->smarty->force_compile || $_template->smarty->force_cache) {
|
||||||
$this->valid = false;
|
$this->valid = false;
|
||||||
} else {
|
} else {
|
||||||
$this->valid = true;
|
$this->valid = true;
|
||||||
@@ -187,6 +182,7 @@ class Smarty_Template_Cached
|
|||||||
Smarty_Internal_Debug::end_cache($_template);
|
Smarty_Internal_Debug::end_cache($_template);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$this->is_locked = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -195,16 +191,17 @@ class Smarty_Template_Cached
|
|||||||
if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties['cache_lifetime']))) {
|
if ($this->valid && $_template->caching === Smarty::CACHING_LIFETIME_SAVED && $_template->properties['cache_lifetime'] >= 0 && (time() > ($_template->cached->timestamp + $_template->properties['cache_lifetime']))) {
|
||||||
$this->valid = false;
|
$this->valid = false;
|
||||||
}
|
}
|
||||||
if (!$this->valid && $_template->smarty->cache_locking) {
|
if ($_template->smarty->cache_locking) {
|
||||||
$this->handler->acquireLock($_template->smarty, $this);
|
if (!$this->valid) {
|
||||||
|
$this->handler->acquireLock($_template->smarty, $this);
|
||||||
return $this->valid;
|
} elseif ($this->is_locked) {
|
||||||
} else {
|
$this->handler->releaseLock($_template->smarty, $this);
|
||||||
return $this->valid;
|
}
|
||||||
}
|
}
|
||||||
|
return $this->valid;
|
||||||
}
|
}
|
||||||
return $this->valid =false;
|
return $this->valid = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Process cached template
|
* Process cached template
|
||||||
|
Reference in New Issue
Block a user