mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- rearrange internal cache
This commit is contained in:
@@ -382,13 +382,6 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public $merge_compiled_includes = false;
|
||||
|
||||
/**
|
||||
* template inheritance merge compiled includes
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
public $inheritance_merge_compiled_includes = true;
|
||||
|
||||
/**
|
||||
* force cache file creation
|
||||
*
|
||||
@@ -646,7 +639,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
* @var int
|
||||
*/
|
||||
public $start_time = 0;
|
||||
|
||||
|
||||
/**
|
||||
* required by the compiler for BC
|
||||
*
|
||||
@@ -680,14 +673,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $obsoleteProperties = array('resource_caching', 'template_resource_caching', 'direct_access_security' , '_dir_perms', '_file_perms', 'plugin_search_order');
|
||||
private static $obsoleteProperties = array('resource_caching', 'template_resource_caching',
|
||||
'direct_access_security', '_dir_perms', '_file_perms',
|
||||
'plugin_search_order');
|
||||
|
||||
/**
|
||||
* Extension object cache
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $extObjCache = array();
|
||||
private static $accessMap = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
|
||||
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
|
||||
'cache_dir' => 'getCacheDir',);
|
||||
|
||||
/**#@-*/
|
||||
|
||||
@@ -1074,7 +1066,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
}
|
||||
$_templateId = $this->_getTemplateId($template, $cache_id, $compile_id);
|
||||
if (isset($this->_cache['isCached'][$_templateId])) {
|
||||
$tpl = $do_clone ? clone $this->_cache['isCached'][$_templateId] : $this->_cache['isCached'][$_templateId];
|
||||
$tpl = $do_clone ? clone $this->_cache['isCached'][$_templateId] : $this->_cache['isCached'][$_templateId];
|
||||
$tpl->parent = $parent;
|
||||
$tpl->tpl_vars = array();
|
||||
$tpl->config_vars = array();
|
||||
@@ -1329,13 +1321,10 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function __get($name)
|
||||
{
|
||||
$allowed = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
|
||||
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
|
||||
'cache_dir' => 'getCacheDir',);
|
||||
|
||||
if (isset($allowed[$name])) {
|
||||
return $this->{$allowed[$name]}();
|
||||
} elseif (in_array($name, $this->obsoleteProperties)) {
|
||||
if (isset(self::$accessMap[$name])) {
|
||||
return $this->{self::$accessMap[$name]}();
|
||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||
return null;
|
||||
} else {
|
||||
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
||||
@@ -1352,13 +1341,9 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public function __set($name, $value)
|
||||
{
|
||||
$allowed = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir',
|
||||
'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir',
|
||||
'cache_dir' => 'setCacheDir',);
|
||||
|
||||
if (isset($allowed[$name])) {
|
||||
$this->{$allowed[$name]}($value);
|
||||
} elseif (in_array($name, $this->obsoleteProperties)) {
|
||||
if (isset(self::$accessMap[$name])) {
|
||||
$this->{self::$accessMap[$name]}($value);
|
||||
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||
return;
|
||||
} else {
|
||||
if (is_object($value) && method_exists($value, $name)) {
|
||||
|
@@ -53,13 +53,6 @@ class Smarty_Internal_Data
|
||||
*/
|
||||
public $config_vars = array();
|
||||
|
||||
/**
|
||||
* universal cache
|
||||
*
|
||||
* @var array()
|
||||
*/
|
||||
public $_cache = array();
|
||||
|
||||
/**
|
||||
* Cache for property information from generic getter/setter
|
||||
* Preloaded with names which should not use with generic getter/setter
|
||||
@@ -336,24 +329,22 @@ class Smarty_Internal_Data
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
static $_resolved_property_name = array();
|
||||
|
||||
if (!isset(Smarty::$extObjCache[$name])) {
|
||||
$smarty = $this->_objType == 1 ? $this : $this->smarty;
|
||||
if (!isset($smarty->_cache['extObjCache'][$name])) {
|
||||
|
||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
||||
if (!isset($this->_property_info[$prop])) {
|
||||
// convert camel case to underscored name
|
||||
$_resolved_property_name[$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY |
|
||||
$smarty->_cache['resolvedProp'][$prop] = $pn = strtolower(join('_', preg_split('/([A-Z][^A-Z]*)/', $prop, - 1, PREG_SPLIT_NO_EMPTY |
|
||||
PREG_SPLIT_DELIM_CAPTURE)));
|
||||
$this->_property_info[$prop] = property_exists($this, $pn) ? 1 : ($this->_objType == 2 &&
|
||||
property_exists($smarty, $pn) ? 2 : 0);
|
||||
}
|
||||
}
|
||||
if ($this->_property_info[$prop]) {
|
||||
$pn = $_resolved_property_name[$prop];
|
||||
$pn = $smarty->_cache['resolvedProp'][$prop];
|
||||
if ($match[1] == 'get') {
|
||||
return $this->_property_info[$prop] == 1 ? $this->$pn : $this->smarty->$pn;
|
||||
} else {
|
||||
@@ -365,10 +356,10 @@ class Smarty_Internal_Data
|
||||
}
|
||||
}
|
||||
if (class_exists($class)) {
|
||||
$callback = array(Smarty::$extObjCache[$name] = new $class(), $name);
|
||||
$callback = array($smarty->_cache['extObjCache'][$name] = new $class(), $name);
|
||||
}
|
||||
} else {
|
||||
$callback = array(Smarty::$extObjCache[$name], $name);
|
||||
$callback = array($smarty->_cache['extObjCache'][$name], $name);
|
||||
}
|
||||
if (isset($callback) && $callback[0]->objMap | $this->_objType) {
|
||||
array_unshift($args, $this);
|
||||
|
@@ -74,6 +74,13 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
public $cache_lifetime = 3600;
|
||||
|
||||
/**
|
||||
* universal cache
|
||||
*
|
||||
* @var array()
|
||||
*/
|
||||
public $_cache = array();
|
||||
|
||||
/**
|
||||
* fetches a rendered Smarty template
|
||||
*
|
||||
|
Reference in New Issue
Block a user