summaryrefslogtreecommitdiff
path: root/lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php')
-rw-r--r--lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php51
1 files changed, 35 insertions, 16 deletions
diff --git a/lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php b/lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php
index bf93a4c..6161844 100644
--- a/lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php
+++ b/lib/smarty3/sysplugins/smarty_internal_cacheresource_file.php
@@ -29,20 +29,31 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
{
$source = &$_template->source;
$smarty = &$_template->smarty;
- $_compile_dir_sep = $smarty->use_sub_dirs ? 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),
- $_template->cache_id) . $_compile_dir_sep;
+ $cached->filepath .= preg_replace(
+ array(
+ '![^\w|]+!',
+ '![|]+!'
+ ),
+ array(
+ '_',
+ $_compile_dir_sep
+ ),
+ $_template->cache_id
+ ) . $_compile_dir_sep;
}
if (isset($_template->compile_id)) {
$cached->filepath .= preg_replace('![^\w]+!', '_', $_template->compile_id) . $_compile_dir_sep;
}
// if use_sub_dirs, break file into directories
if ($smarty->use_sub_dirs) {
- $cached->filepath .= $_filepath[ 0 ] . $_filepath[ 1 ] . DS . $_filepath[ 2 ] . $_filepath[ 3 ] . DS .
- $_filepath[ 4 ] . $_filepath[ 5 ] . 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);
@@ -83,12 +94,14 @@ 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,
- $update = false)
- {
+ public function process(
+ Smarty_Internal_Template $_smarty_tpl,
+ Smarty_Template_Cached $cached = null,
+ $update = false
+ ) {
$_smarty_tpl->cached->valid = false;
if ($update && defined('HHVM_VERSION')) {
- eval("?>" . file_get_contents($_smarty_tpl->cached->filepath));
+ eval('?>' . file_get_contents($_smarty_tpl->cached->filepath));
return true;
} else {
return @include $_smarty_tpl->cached->filepath;
@@ -101,14 +114,20 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
* @param Smarty_Internal_Template $_template template object
* @param string $content content to cache
*
- * @return boolean success
+ * @return bool success
+ * @throws \SmartyException
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{
- if ($_template->smarty->ext->_writeFile->writeFile($_template->cached->filepath, $content,
- $_template->smarty) === true
+ if ($_template->smarty->ext->_writeFile->writeFile(
+ $_template->cached->filepath,
+ $content,
+ $_template->smarty
+ ) === true
) {
- if (function_exists('opcache_invalidate') && 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($_template->cached->filepath, true);
} elseif (function_exists('apc_compile_file')) {
apc_compile_file($_template->cached->filepath);
@@ -126,7 +145,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
/**
* Read cached template from cache
*
- * @param Smarty_Internal_Template $_template template object
+ * @param Smarty_Internal_Template $_template template object
*
* @return string content
*/
@@ -148,7 +167,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
- return Smarty_Internal_Extension_Clear::clear($smarty, null, null, null, $exp_time);
+ return $smarty->ext->_cacheResourceFile->clear($smarty, null, null, null, $exp_time);
}
/**
@@ -164,7 +183,7 @@ class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
- return Smarty_Internal_Extension_Clear::clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
+ return $smarty->ext->_cacheResourceFile->clear($smarty, $resource_name, $cache_id, $compile_id, $exp_time);
}
/**