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 * @param Source $source source object
*/ */
public function populateTimestamp(Source $source) { public function populateTimestamp(Source $source) {
if (!$source->exists && $path = $this->getFilePath($source->name, $source->getSmarty(), $source->isConfig)) { $path = $this->getFilePath($source->name, $source->getSmarty(), $source->isConfig);
$source->timestamp = $source->exists = is_file($path); if (!$source->exists) {
$source->exists = ($path !== false && is_file($path));
} }
if ($source->exists && $path) { if ($source->exists && $path !== false) {
$source->timestamp = filemtime($path); $source->timestamp = filemtime($path);
} else {
$source->timestamp = 0;
} }
} }

View File

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

View File

@@ -136,7 +136,7 @@ class Compiled extends GeneratedPhpFile {
if ($this->exists && !$_smarty_tpl->getSmarty()->force_compile if ($this->exists && !$_smarty_tpl->getSmarty()->force_compile
&& !($_smarty_tpl->compile_check && $_smarty_tpl->getSource()->getTimeStamp() > $this->getTimeStamp()) && !($_smarty_tpl->compile_check && $_smarty_tpl->getSource()->getTimeStamp() > $this->getTimeStamp())
) { ) {
$this->loadCompiledTemplate($_smarty_tpl); $this->loadCompiledTemplate($_smarty_tpl, false);
} }
if (!$this->isValid) { if (!$this->isValid) {
@@ -241,16 +241,19 @@ class Compiled extends GeneratedPhpFile {
* HHVM requires a workaround because of a PHP incompatibility * 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 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) { private function loadCompiledTemplate(Template $_smarty_tpl, bool $invalidateCachedFiles = true) {
if (function_exists('opcache_invalidate') if ($invalidateCachedFiles) {
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1) 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')) { opcache_invalidate($this->filepath, true);
apc_compile_file($this->filepath); } elseif (function_exists('apc_compile_file')) {
apc_compile_file($this->filepath);
}
} }
if (defined('HHVM_VERSION')) { if (defined('HHVM_VERSION')) {
eval('?>' . file_get_contents($this->filepath)); eval('?>' . file_get_contents($this->filepath));