mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
fixed cache_paths bug, simplified filename assembly logic
This commit is contained in:
@@ -1165,13 +1165,21 @@ class Smarty
|
|||||||
{
|
{
|
||||||
static $_cache_info = array();
|
static $_cache_info = array();
|
||||||
|
|
||||||
$this->_cache_paths_file = $this->compile_dir
|
define('SMARTY_COMPILE_DIR_SEP', $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^');
|
||||||
|
|
||||||
|
$this->_cache_paths_file =
|
||||||
|
$this->compile_dir
|
||||||
. DIRECTORY_SEPARATOR
|
. DIRECTORY_SEPARATOR
|
||||||
. '_smarty_cached_paths'
|
. '_smarty_cached_paths'
|
||||||
. DIRECTORY_SEPARATOR
|
. SMARTY_COMPILE_DIR_SEP
|
||||||
. urlencode($resource_name)
|
. urlencode($resource_name)
|
||||||
. '.php';
|
. '.php';
|
||||||
|
|
||||||
|
if(!$this->force_compile
|
||||||
|
&& file_exists($this->_cache_paths_file)) {
|
||||||
|
include_once($this->_cache_paths_file);
|
||||||
|
}
|
||||||
|
|
||||||
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE);
|
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(error_reporting() & ~E_NOTICE);
|
||||||
|
|
||||||
if($this->security && !in_array($this->template_dir, $this->secure_dir)) {
|
if($this->security && !in_array($this->template_dir, $this->secure_dir)) {
|
||||||
@@ -1415,11 +1423,6 @@ class Smarty
|
|||||||
if (isset($this->_cache_paths['plugins'][$_cache_paths_key])) {
|
if (isset($this->_cache_paths['plugins'][$_cache_paths_key])) {
|
||||||
return $this->_cache_paths['plugins'][$_cache_paths_key];
|
return $this->_cache_paths['plugins'][$_cache_paths_key];
|
||||||
}
|
}
|
||||||
if (!$this->force_compile
|
|
||||||
&& !isset($this->_cache_paths)
|
|
||||||
&& file_exists($this->_cache_paths_file)) {
|
|
||||||
include_once($this->_cache_paths_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_params = array('type' => $type, 'name' => $name);
|
$_params = array('type' => $type, 'name' => $name);
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_plugin_filepath.php');
|
||||||
@@ -1685,11 +1688,6 @@ class Smarty
|
|||||||
if (isset($this->_cache_paths['auto_file'][$_cache_paths_key])) {
|
if (isset($this->_cache_paths['auto_file'][$_cache_paths_key])) {
|
||||||
return $this->_cache_paths['auto_file'][$_cache_paths_key];
|
return $this->_cache_paths['auto_file'][$_cache_paths_key];
|
||||||
}
|
}
|
||||||
if(!$this->force_compile
|
|
||||||
&& !isset($this->_cache_paths)
|
|
||||||
&& file_exists($this->_cache_paths_file)) {
|
|
||||||
include_once($this->_cache_paths_file);
|
|
||||||
}
|
|
||||||
|
|
||||||
$_params = array('auto_base' => $auto_base, 'auto_source' => $auto_source, 'auto_id' => $auto_id);
|
$_params = array('auto_base' => $auto_base, 'auto_source' => $auto_source, 'auto_id' => $auto_id);
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_auto_filename.php');
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.assemble_auto_filename.php');
|
||||||
|
@@ -17,17 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
function smarty_core_assemble_auto_filename($params, &$smarty)
|
function smarty_core_assemble_auto_filename($params, &$smarty)
|
||||||
{
|
{
|
||||||
static $_dir_sep = null;
|
|
||||||
static $_dir_sep_enc = null;
|
|
||||||
|
|
||||||
if(!isset($_dir_sep)) {
|
|
||||||
$_dir_sep_enc = urlencode(DIRECTORY_SEPARATOR);
|
|
||||||
if($smarty->use_sub_dirs) {
|
|
||||||
$_dir_sep = DIRECTORY_SEPARATOR;
|
|
||||||
} else {
|
|
||||||
$_dir_sep = '^';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(@is_dir($params['auto_base'])) {
|
if(@is_dir($params['auto_base'])) {
|
||||||
$_return = $params['auto_base'] . DIRECTORY_SEPARATOR;
|
$_return = $params['auto_base'] . DIRECTORY_SEPARATOR;
|
||||||
@@ -43,22 +32,18 @@ function smarty_core_assemble_auto_filename($params, &$smarty)
|
|||||||
// make auto_id safe for directory names
|
// make auto_id safe for directory names
|
||||||
$params['auto_id'] = str_replace('%7C','|',(urlencode($params['auto_id'])));
|
$params['auto_id'] = str_replace('%7C','|',(urlencode($params['auto_id'])));
|
||||||
// split into separate directories
|
// split into separate directories
|
||||||
$params['auto_id'] = str_replace('|', $_dir_sep, $params['auto_id']);
|
$params['auto_id'] = str_replace('|', SMARTY_COMPILE_DIR_SEP, $params['auto_id']);
|
||||||
$_return .= $params['auto_id'] . $_dir_sep;
|
$_return .= $params['auto_id'] . SMARTY_COMPILE_DIR_SEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isset($params['auto_source'])) {
|
if(isset($params['auto_source'])) {
|
||||||
// make source name safe for filename
|
// make source name safe for filename
|
||||||
if($smarty->use_sub_dirs) {
|
$_filename = urlencode(basename($params['auto_source']));
|
||||||
$_filename = urlencode(basename($params['auto_source']));
|
$_crc32 = crc32($params['auto_source']) . SMARTY_COMPILE_DIR_SEP;
|
||||||
$_crc32 = crc32($params['auto_source']) . $_dir_sep;
|
// prepend %% to avoid name conflicts with
|
||||||
// prepend %% to avoid name conflicts with
|
// with $params['auto_id'] names
|
||||||
// with $params['auto_id'] names
|
$_crc32 = '%%' . substr($_crc32,0,3) . SMARTY_COMPILE_DIR_SEP . '%%' . $_crc32;
|
||||||
$_crc32 = '%%' . substr($_crc32,0,3) . $_dir_sep . '%%' . $_crc32;
|
$_return .= $_crc32 . $_filename;
|
||||||
$_return .= $_crc32 . $_filename;
|
|
||||||
} else {
|
|
||||||
$_return .= str_replace($_dir_sep_enc,'^',urlencode($params['auto_source']));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $_return;
|
return $_return;
|
||||||
|
@@ -15,7 +15,7 @@
|
|||||||
function smarty_core_write_cache_paths_file($params, &$smarty)
|
function smarty_core_write_cache_paths_file($params, &$smarty)
|
||||||
{
|
{
|
||||||
$_compiled_content = function_exists('var_export') ? var_export($smarty->_cache_paths, true) : "unserialize('" . serialize($smarty->_cache_paths) . "')";
|
$_compiled_content = function_exists('var_export') ? var_export($smarty->_cache_paths, true) : "unserialize('" . serialize($smarty->_cache_paths) . "')";
|
||||||
$_compiled_content = '<?php $smarty->_cache_paths = ' . $_compiled_content . '; ?>';
|
$_compiled_content = '<?php $this->_cache_paths = ' . $_compiled_content . '; ?>';
|
||||||
$_params = array('compile_path' => $smarty->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time());
|
$_params = array('compile_path' => $smarty->_cache_paths_file, 'compiled_content' => $_compiled_content, 'resource_timestamp' => time());
|
||||||
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
|
require_once(SMARTY_DIR . 'core' . DIRECTORY_SEPARATOR . 'core.write_compiled_resource.php');
|
||||||
return smarty_core_write_compiled_resource($_params, $smarty);
|
return smarty_core_write_compiled_resource($_params, $smarty);
|
||||||
|
Reference in New Issue
Block a user