mirror of
https://github.com/smarty-php/smarty.git
synced 2026-04-29 02:03:31 +02:00
- optimization replace internal Smarty::$ds property by DIRECTORY_SEPARATOR (reverted from commit f7a5316205) (reverted from commit beaa293eb3)
This commit is contained in:
@@ -29,13 +29,14 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
{
|
||||
$source = &$_template->source;
|
||||
$smarty = &$_template->smarty;
|
||||
$_compile_dir_sep = $smarty->use_sub_dirs ? $smarty->ds : '^';
|
||||
$_compile_dir_sep = $smarty->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
|
||||
$_filepath = sha1($source->uid . $smarty->_joined_template_dir);
|
||||
$cached->filepath = $smarty->getCacheDir();
|
||||
if (isset($_template->cache_id)) {
|
||||
$cached->filepath .= preg_replace(array('![^\w|]+!',
|
||||
'![|]+!'), array('_',
|
||||
$_compile_dir_sep),
|
||||
'![|]+!'),
|
||||
array('_',
|
||||
$_compile_dir_sep),
|
||||
$_template->cache_id) . $_compile_dir_sep;
|
||||
}
|
||||
if (isset($_template->compile_id)) {
|
||||
@@ -43,9 +44,10 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
}
|
||||
// if use_sub_dirs, break file into directories
|
||||
if ($smarty->use_sub_dirs) {
|
||||
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . $smarty->ds . $_filepath[ 2 ] . $_filepath[ 3 ] .
|
||||
$smarty->ds .
|
||||
$_filepath[ 4 ] . $_filepath[ 5 ] . $smarty->ds;
|
||||
$cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . DIRECTORY_SEPARATOR . $_filepath[ 2 ] .
|
||||
$_filepath[ 3 ] .
|
||||
DIRECTORY_SEPARATOR .
|
||||
$_filepath[ 4 ] . $_filepath[ 5 ] . DIRECTORY_SEPARATOR;
|
||||
}
|
||||
$cached->filepath .= $_filepath;
|
||||
$basename = $source->handler->getBasename($source);
|
||||
@@ -86,7 +88,8 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*
|
||||
* @return boolean true or false if the cached content does not exist
|
||||
*/
|
||||
public function process(Smarty_Internal_Template $_smarty_tpl, Smarty_Template_Cached $cached = null,
|
||||
public function process(Smarty_Internal_Template $_smarty_tpl,
|
||||
Smarty_Template_Cached $cached = null,
|
||||
$update = false)
|
||||
{
|
||||
$_smarty_tpl->cached->valid = false;
|
||||
@@ -108,14 +111,15 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
|
||||
*/
|
||||
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
|
||||
{
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content,
|
||||
if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath,
|
||||
$content,
|
||||
$_template->smarty) === true
|
||||
) {
|
||||
if (function_exists('opcache_invalidate') &&
|
||||
(!function_exists('ini_get') || strlen(ini_get("opcache.restrict_api"))) < 1
|
||||
) {
|
||||
opcache_invalidate($_template->cached->filepath, true);
|
||||
} elseif (function_exists('apc_compile_file')) {
|
||||
} else if (function_exists('apc_compile_file')) {
|
||||
apc_compile_file($_template->cached->filepath);
|
||||
}
|
||||
$cached = $_template->cached;
|
||||
|
||||
Reference in New Issue
Block a user