mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-03 19:30:49 +02:00
- improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24)
This commit is contained in:
@@ -61,8 +61,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
$cached->lock_id = $_lock_dir . sha1($_cache_id . $_compile_id . $_template->source->uid) . '.lock';
|
||||
}
|
||||
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
||||
$cached->timestamp = @filemtime($cached->filepath);
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
$cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,8 +76,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||
{
|
||||
$cached->timestamp = @filemtime($cached->filepath);
|
||||
$cached->exists = !!$cached->timestamp;
|
||||
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -108,13 +112,13 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
{
|
||||
$obj = new Smarty_Internal_Write_File();
|
||||
if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
||||
$_template->cached->exists = !!$_template->cached->timestamp;
|
||||
if ($_template->cached->exists) {
|
||||
$cached = $_template->cached;
|
||||
$cached->timestamp = $cached->exists = is_file( $cached->filepath);
|
||||
if ($cached->exists) {
|
||||
$cached->timestamp = filemtime($cached->filepath);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -278,9 +282,12 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
} else {
|
||||
clearstatcache();
|
||||
}
|
||||
$t = @filemtime($cached->lock_id);
|
||||
|
||||
return $t && (time() - $t < $smarty->locking_timeout);
|
||||
if (is_file($cached->lock_id)) {
|
||||
$t = @filemtime($cached->lock_id);
|
||||
return $t && (time() - $t < $smarty->locking_timeout);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user