Update Smarty: v5.4.0

This commit is contained in:
2024-08-19 11:39:40 +09:00
parent d1fe561041
commit ea4162dfa6
3 changed files with 19 additions and 14 deletions

View File

@@ -56,11 +56,14 @@ class FilePlugin extends BasePlugin {
* @param Source $source source object
*/
public function populateTimestamp(Source $source) {
if (!$source->exists && $path = $this->getFilePath($source->name, $source->getSmarty(), $source->isConfig)) {
$source->timestamp = $source->exists = is_file($path);
$path = $this->getFilePath($source->name, $source->getSmarty(), $source->isConfig);
if (!$source->exists) {
$source->exists = ($path !== false && is_file($path));
}
if ($source->exists && $path) {
if ($source->exists && $path !== false) {
$source->timestamp = filemtime($path);
} else {
$source->timestamp = 0;
}
}

View File

@@ -54,7 +54,7 @@ class Smarty extends \Smarty\TemplateBase {
/**
* smarty version
*/
const SMARTY_VERSION = '5.3.1';
const SMARTY_VERSION = '5.4.0';
/**
* define caching modes
@@ -527,7 +527,6 @@ class Smarty extends \Smarty\TemplateBase {
$this->extensions[] = new CoreExtension();
$this->extensions[] = new DefaultExtension();
// print "EXT: <pre>" . print_r($this->extensions, true) . "</pre>>";
$this->extensions[] = $this->BCPluginsAdapter;
$this->cacheResource = new File();

View File

@@ -136,7 +136,7 @@ class Compiled extends GeneratedPhpFile {
if ($this->exists && !$_smarty_tpl->getSmarty()->force_compile
&& !($_smarty_tpl->compile_check && $_smarty_tpl->getSource()->getTimeStamp() > $this->getTimeStamp())
) {
$this->loadCompiledTemplate($_smarty_tpl);
$this->loadCompiledTemplate($_smarty_tpl, false);
}
if (!$this->isValid) {
@@ -241,16 +241,19 @@ class Compiled extends GeneratedPhpFile {
* HHVM requires a workaround because of a PHP incompatibility
*
* @param Template $_smarty_tpl do not change/remove variable name, is used by compiled template
* @param bool $invalidateCachedFiles forces a revalidation of the file in opcache or apc cache (if available)
*
*/
private function loadCompiledTemplate(Template $_smarty_tpl) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
) {
opcache_invalidate($this->filepath, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($this->filepath);
private function loadCompiledTemplate(Template $_smarty_tpl, bool $invalidateCachedFiles = true) {
if ($invalidateCachedFiles) {
if (function_exists('opcache_invalidate')
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
) {
opcache_invalidate($this->filepath, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($this->filepath);
}
}
if (defined('HHVM_VERSION')) {
eval('?>' . file_get_contents($this->filepath));