mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-17 22:45:20 +02:00
- bugfix Smarty version was not filled in header comment of compiled and cached files
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit 1e787d08f1
)
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
*/
|
||||
class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
{
|
||||
|
||||
/**
|
||||
* nocache hash
|
||||
*
|
||||
@@ -48,22 +49,21 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
$this->filepath = $smarty->getCompileDir();
|
||||
if (isset($_template->compile_id)) {
|
||||
$this->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) .
|
||||
($smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^');
|
||||
($smarty->use_sub_dirs ? $smarty->ds : '^');
|
||||
}
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($smarty->use_sub_dirs) {
|
||||
$this->filepath .= $source->uid[ 0 ] . $source->uid[ 1 ] . DIRECTORY_SEPARATOR . $source->uid[ 2 ] .
|
||||
$source->uid[ 3 ] . DIRECTORY_SEPARATOR . $source->uid[ 4 ] . $source->uid[ 5 ] .
|
||||
DIRECTORY_SEPARATOR;
|
||||
$this->filepath .= $source->uid[ 0 ] . $source->uid[ 1 ] . $smarty->ds . $source->uid[ 2 ] .
|
||||
$source->uid[ 3 ] . $smarty->ds . $source->uid[ 4 ] . $source->uid[ 5 ] . $smarty->ds;
|
||||
}
|
||||
$this->filepath .= $source->uid . '_';
|
||||
if ($source->isConfig) {
|
||||
$this->filepath .= (int)$smarty->config_read_hidden + (int)$smarty->config_booleanize * 2 +
|
||||
(int)$smarty->config_overwrite * 4;
|
||||
$this->filepath .= (int) $smarty->config_read_hidden + (int) $smarty->config_booleanize * 2 +
|
||||
(int) $smarty->config_overwrite * 4;
|
||||
} else {
|
||||
$this->filepath .= (int)$smarty->merge_compiled_includes + (int)$smarty->escape_html * 2 +
|
||||
$this->filepath .= (int) $smarty->merge_compiled_includes + (int) $smarty->escape_html * 2 +
|
||||
(($smarty->merge_compiled_includes && $source->type === 'extends') ?
|
||||
(int)$smarty->extends_recursion * 4 : 0);
|
||||
(int) $smarty->extends_recursion * 4 : 0);
|
||||
}
|
||||
$this->filepath .= '.' . $source->type;
|
||||
$basename = $source->handler->getBasename($source);
|
||||
@@ -134,7 +134,7 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
$smarty = &$_smarty_tpl->smarty;
|
||||
if ($source->handler->recompiled) {
|
||||
$source->handler->process($_smarty_tpl);
|
||||
} else if (!$source->handler->uncompiled) {
|
||||
} elseif (!$source->handler->uncompiled) {
|
||||
if (!$this->exists || $smarty->force_compile ||
|
||||
($smarty->compile_check && $source->getTimeStamp() > $this->getTimeStamp())
|
||||
) {
|
||||
@@ -218,6 +218,28 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load fresh compiled template by including the PHP file
|
||||
* HHVM requires a work around because of a PHP incompatibility
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
*/
|
||||
private function loadCompiledTemplate(Smarty_Internal_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);
|
||||
}
|
||||
if (defined('HHVM_VERSION')) {
|
||||
eval("?>" . file_get_contents($this->filepath));
|
||||
} else {
|
||||
include($this->filepath);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Read compiled content from handler
|
||||
*
|
||||
@@ -232,26 +254,4 @@ class Smarty_Template_Compiled extends Smarty_Template_Resource_Base
|
||||
}
|
||||
return isset($this->content) ? $this->content : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load fresh compiled template by including the PHP file
|
||||
* HHVM requires a work around because of a PHP incompatibility
|
||||
*
|
||||
* @param \Smarty_Internal_Template $_smarty_tpl do not change variable name, is used by compiled template
|
||||
*/
|
||||
private function loadCompiledTemplate(Smarty_Internal_Template $_smarty_tpl)
|
||||
{
|
||||
if (function_exists('opcache_invalidate')
|
||||
&& (!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api")) < 1)
|
||||
) {
|
||||
opcache_invalidate($this->filepath, true);
|
||||
} else if (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($this->filepath);
|
||||
}
|
||||
if (defined('HHVM_VERSION')) {
|
||||
eval("?>" . file_get_contents($this->filepath));
|
||||
} else {
|
||||
include($this->filepath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user