mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44:27 +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:
@@ -1,7 +1,8 @@
|
|||||||
===== 3.1.22-dev ===== (xx.xx.2015)
|
===== 3.1.22-dev ===== (xx.xx.2015)
|
||||||
04.05.2015
|
04.05.2015
|
||||||
- bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22)
|
- bugfix Smarty_Resource::parseResourceName incompatible with Google AppEngine (https://github.com/smarty-php/smarty/issues/22)
|
||||||
|
- improvement use is_file() checks to avoid errors suppressed by @ which could still cause problems (https://github.com/smarty-php/smarty/issues/24)
|
||||||
|
|
||||||
28.04.2015
|
28.04.2015
|
||||||
- bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2nd fix
|
- bugfix plugins of merged subtemplates not loaded in 3.1.22-dev (forum topic 25508) 2nd fix
|
||||||
|
|
||||||
|
@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.22-dev/22';
|
const SMARTY_VERSION = '3.1.22-dev/23';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -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->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->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
$cached->exists = is_file($cached->filepath);
|
||||||
$cached->exists = !!$cached->timestamp;
|
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)
|
public function populateTimestamp(Smarty_Template_Cached $cached)
|
||||||
{
|
{
|
||||||
$cached->timestamp = @filemtime($cached->filepath);
|
$cached->timestamp = $cached->exists = is_file($cached->filepath);
|
||||||
$cached->exists = !!$cached->timestamp;
|
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();
|
$obj = new Smarty_Internal_Write_File();
|
||||||
if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
if ($obj->writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
|
||||||
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
|
$cached = $_template->cached;
|
||||||
$_template->cached->exists = !!$_template->cached->timestamp;
|
$cached->timestamp = $cached->exists = is_file( $cached->filepath);
|
||||||
if ($_template->cached->exists) {
|
if ($cached->exists) {
|
||||||
|
$cached->timestamp = filemtime($cached->filepath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -278,9 +282,12 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
|||||||
} else {
|
} else {
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
}
|
}
|
||||||
$t = @filemtime($cached->lock_id);
|
if (is_file($cached->lock_id)) {
|
||||||
|
$t = @filemtime($cached->lock_id);
|
||||||
return $t && (time() - $t < $smarty->locking_timeout);
|
return $t && (time() - $t < $smarty->locking_timeout);
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -35,8 +35,10 @@ class Smarty_Internal_Extension_DefaultTemplateHandler
|
|||||||
$_return = call_user_func_array($default_handler,
|
$_return = call_user_func_array($default_handler,
|
||||||
array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
|
array($source->type, $source->name, &$_content, &$_timestamp, $source->smarty));
|
||||||
if (is_string($_return)) {
|
if (is_string($_return)) {
|
||||||
$source->timestamp = @filemtime($_return);
|
$source->exists = is_file($_return);
|
||||||
$source->exists = !!$source->timestamp;
|
if ($source->exists) {
|
||||||
|
$source->timestamp = filemtime($_return);
|
||||||
|
}
|
||||||
$source->filepath = $_return;
|
$source->filepath = $_return;
|
||||||
} elseif ($_return === true) {
|
} elseif ($_return === true) {
|
||||||
$source->content = $_content;
|
$source->content = $_content;
|
||||||
|
@@ -169,8 +169,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
|||||||
|
|
||||||
$source->uid = sha1(getcwd() . $source->filepath);
|
$source->uid = sha1(getcwd() . $source->filepath);
|
||||||
if ($source->smarty->compile_check && !isset($source->timestamp)) {
|
if ($source->smarty->compile_check && !isset($source->timestamp)) {
|
||||||
$source->timestamp = @filemtime($source->filepath);
|
$source->timestamp = $source->exists = is_file($source->filepath);
|
||||||
$source->exists = !!$source->timestamp;
|
if ($source->exists) {
|
||||||
|
$source->timestamp = @filemtime($source->filepath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$source->timestamp = false;
|
$source->timestamp = false;
|
||||||
@@ -185,8 +187,10 @@ class Smarty_Internal_Resource_File extends Smarty_Resource
|
|||||||
*/
|
*/
|
||||||
public function populateTimestamp(Smarty_Template_Source $source)
|
public function populateTimestamp(Smarty_Template_Source $source)
|
||||||
{
|
{
|
||||||
$source->timestamp = @filemtime($source->filepath);
|
$source->timestamp = $source->exists = is_file($source->filepath);
|
||||||
$source->exists = !!$source->timestamp;
|
if ($source->exists) {
|
||||||
|
$source->timestamp = @filemtime($source->filepath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -599,8 +599,8 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
|||||||
$mtime = $this->source->timestamp;
|
$mtime = $this->source->timestamp;
|
||||||
} else {
|
} else {
|
||||||
// file and php types can be checked without loading the respective resource handlers
|
// file and php types can be checked without loading the respective resource handlers
|
||||||
$mtime = @filemtime($_file_to_check[0]);
|
$mtime = is_file($_file_to_check[0]) ? @filemtime($_file_to_check[0]) : false;
|
||||||
}
|
}
|
||||||
} elseif ($_file_to_check[2] == 'string') {
|
} elseif ($_file_to_check[2] == 'string') {
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
|
@@ -55,7 +55,9 @@ class Smarty_Internal_Write_File
|
|||||||
*/
|
*/
|
||||||
if (Smarty::$_IS_WINDOWS) {
|
if (Smarty::$_IS_WINDOWS) {
|
||||||
// remove original file
|
// remove original file
|
||||||
@unlink($_filepath);
|
if (is_file($_filepath)) {
|
||||||
|
@unlink($_filepath);
|
||||||
|
}
|
||||||
// rename tmp file
|
// rename tmp file
|
||||||
$success = @rename($_tmp_file, $_filepath);
|
$success = @rename($_tmp_file, $_filepath);
|
||||||
} else {
|
} else {
|
||||||
@@ -63,17 +65,17 @@ class Smarty_Internal_Write_File
|
|||||||
$success = @rename($_tmp_file, $_filepath);
|
$success = @rename($_tmp_file, $_filepath);
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
// remove original file
|
// remove original file
|
||||||
@unlink($_filepath);
|
if (is_file($_filepath)) {
|
||||||
|
@unlink($_filepath);
|
||||||
|
}
|
||||||
// rename tmp file
|
// rename tmp file
|
||||||
$success = @rename($_tmp_file, $_filepath);
|
$success = @rename($_tmp_file, $_filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$success) {
|
if (!$success) {
|
||||||
error_reporting($_error_reporting);
|
error_reporting($_error_reporting);
|
||||||
throw new SmartyException("unable to write file {$_filepath}");
|
throw new SmartyException("unable to write file {$_filepath}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($smarty->_file_perms !== null) {
|
if ($smarty->_file_perms !== null) {
|
||||||
// set file permissions
|
// set file permissions
|
||||||
chmod($_filepath, $smarty->_file_perms);
|
chmod($_filepath, $smarty->_file_perms);
|
||||||
|
@@ -130,8 +130,10 @@ class Smarty_Template_Compiled
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->filepath = $_compile_dir . $_filepath . '.' . $_template->source->type . $_basename . $_cache . '.php';
|
$this->filepath = $_compile_dir . $_filepath . '.' . $_template->source->type . $_basename . $_cache . '.php';
|
||||||
$this->timestamp = @filemtime($this->filepath);
|
$this->timestamp = $this->exists = is_file($this->filepath);
|
||||||
$this->exists = !!$this->timestamp;
|
if ($this->exists) {
|
||||||
|
$this->timestamp = @filemtime($this->filepath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -252,12 +254,12 @@ class Smarty_Template_Compiled
|
|||||||
if (!$_template->source->recompiled) {
|
if (!$_template->source->recompiled) {
|
||||||
$obj = new Smarty_Internal_Write_File();
|
$obj = new Smarty_Internal_Write_File();
|
||||||
if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) {
|
if ($obj->writeFile($this->filepath, $code, $_template->smarty) === true) {
|
||||||
$this->timestamp = @filemtime($this->filepath);
|
$this->timestamp = $this->exists = is_file($this->filepath);
|
||||||
$this->exists = !!$this->timestamp;
|
|
||||||
if ($this->exists) {
|
if ($this->exists) {
|
||||||
|
$this->timestamp = @filemtime($this->filepath);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
$this->code = $code;
|
$this->code = $code;
|
||||||
|
Reference in New Issue
Block a user