mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
- bugfix remove deleted files by clear_cache() and clear_compiled_template() from
ACP cache if present, add some is_file() checks to avoid possible warnings on filemtime() caused by above functions. https://github.com/smarty-php/smarty/issues/341
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
21.5.2017
|
21.5.2017
|
||||||
- bugfix remove special treatment of classes implementing ArrayAccess in {foreach}
|
- bugfix remove special treatment of classes implementing ArrayAccess in {foreach}
|
||||||
https://github.com/smarty-php/smarty/issues/332
|
https://github.com/smarty-php/smarty/issues/332
|
||||||
|
- bugfix remove deleted files by clear_cache() and clear_compiled_template() from
|
||||||
|
ACP cache if present, add some is_file() checks to avoid possible warnings on filemtime()
|
||||||
|
caused by above functions.
|
||||||
|
https://github.com/smarty-php/smarty/issues/341
|
||||||
|
|
||||||
19.5.2017
|
19.5.2017
|
||||||
- change properties $accessMap and $obsoleteProperties from private to protected
|
- change properties $accessMap and $obsoleteProperties from private to protected
|
||||||
|
@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.32-dev-5';
|
const SMARTY_VERSION = '3.1.32-dev-6';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -101,7 +101,7 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
|||||||
$_resource_part_2_length) == 0))
|
$_resource_part_2_length) == 0))
|
||||||
) {
|
) {
|
||||||
if (isset($exp_time)) {
|
if (isset($exp_time)) {
|
||||||
if (time() - @filemtime($_filepath) >= $exp_time) {
|
if (is_file($_filepath) && time() - @filemtime($_filepath) >= $exp_time) {
|
||||||
$unlink = true;
|
$unlink = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -109,12 +109,14 @@ class Smarty_Internal_Method_ClearCompiledTemplate
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($unlink && @unlink($_filepath)) {
|
if ($unlink && is_file($_filepath) && @unlink($_filepath)) {
|
||||||
$_count ++;
|
$_count ++;
|
||||||
if (function_exists('opcache_invalidate')
|
if (function_exists('opcache_invalidate')
|
||||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||||
) {
|
) {
|
||||||
opcache_invalidate($_filepath, true);
|
opcache_invalidate($_filepath, true);
|
||||||
|
} elseif (function_exists('apc_delete_file')) {
|
||||||
|
apc_delete_file($_filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -111,24 +111,28 @@ class Smarty_Internal_Runtime_CacheResourceFile
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// expired ?
|
if (is_file($_filepath)) {
|
||||||
if (isset($exp_time)) {
|
// expired ?
|
||||||
if ($exp_time < 0) {
|
if (isset($exp_time)) {
|
||||||
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
|
if ($exp_time < 0) {
|
||||||
if ($_time < (@filemtime($_file) + $match[ 1 ])) {
|
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_filepath), $match);
|
||||||
continue;
|
if ($_time < (@filemtime($_filepath) + $match[ 1 ])) {
|
||||||
}
|
continue;
|
||||||
} else {
|
}
|
||||||
if ($_time - @filemtime($_file) < $exp_time) {
|
} else {
|
||||||
continue;
|
if ($_time - @filemtime($_filepath) < $exp_time) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
$_count += @unlink($_filepath) ? 1 : 0;
|
||||||
$_count += @unlink($_filepath) ? 1 : 0;
|
if (function_exists('opcache_invalidate')
|
||||||
if (function_exists('opcache_invalidate')
|
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
) {
|
||||||
) {
|
opcache_invalidate($_filepath, true);
|
||||||
opcache_invalidate($_filepath, true);
|
} elseif (function_exists('apc_delete_file')) {
|
||||||
|
apc_delete_file($_filepath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -173,8 +173,8 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
|||||||
$this->nocache_hash = null;
|
$this->nocache_hash = null;
|
||||||
$this->unifunc = null;
|
$this->unifunc = null;
|
||||||
// compile locking
|
// compile locking
|
||||||
$saved_timestamp = $_template->source->handler->recompiled ? false : $this->getTimeStamp();
|
if ($saved_timestamp = (!$_template->source->handler->recompiled && is_file($this->filepath))) {
|
||||||
if ($saved_timestamp) {
|
$saved_timestamp = $this->getTimeStamp();
|
||||||
touch($this->filepath);
|
touch($this->filepath);
|
||||||
}
|
}
|
||||||
// compile locking
|
// compile locking
|
||||||
@@ -185,7 +185,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
|||||||
}
|
}
|
||||||
catch (Exception $e) {
|
catch (Exception $e) {
|
||||||
// restore old timestamp in case of error
|
// restore old timestamp in case of error
|
||||||
if ($saved_timestamp) {
|
if ($saved_timestamp && is_file($this->filepath)) {
|
||||||
touch($this->filepath, $saved_timestamp);
|
touch($this->filepath, $saved_timestamp);
|
||||||
}
|
}
|
||||||
unset($_template->compiler);
|
unset($_template->compiler);
|
||||||
@@ -229,6 +229,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
|||||||
if (function_exists('opcache_invalidate')
|
if (function_exists('opcache_invalidate')
|
||||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||||
) {
|
) {
|
||||||
|
opcache_invalidate($this->filepath, true);
|
||||||
} elseif (function_exists('apc_compile_file')) {
|
} elseif (function_exists('apc_compile_file')) {
|
||||||
apc_compile_file($this->filepath);
|
apc_compile_file($this->filepath);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user