mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44: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;
|
public $merge_compiled_includes = false;
|
||||||
|
|
||||||
/**
|
|
||||||
* template inheritance merge compiled includes
|
|
||||||
*
|
|
||||||
* @var boolean
|
|
||||||
*/
|
|
||||||
public $inheritance_merge_compiled_includes = true;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* force cache file creation
|
* force cache file creation
|
||||||
*
|
*
|
||||||
@@ -680,14 +673,13 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*
|
*
|
||||||
* @var array
|
* @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');
|
||||||
|
|
||||||
/**
|
private static $accessMap = array('template_dir' => 'getTemplateDir', 'config_dir' => 'getConfigDir',
|
||||||
* Extension object cache
|
'plugins_dir' => 'getPluginsDir', 'compile_dir' => 'getCompileDir',
|
||||||
*
|
'cache_dir' => 'getCacheDir',);
|
||||||
* @var array
|
|
||||||
*/
|
|
||||||
public static $extObjCache = array();
|
|
||||||
|
|
||||||
/**#@-*/
|
/**#@-*/
|
||||||
|
|
||||||
@@ -1329,13 +1321,10 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
*/
|
*/
|
||||||
public function __get($name)
|
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])) {
|
if (isset(self::$accessMap[$name])) {
|
||||||
return $this->{$allowed[$name]}();
|
return $this->{self::$accessMap[$name]}();
|
||||||
} elseif (in_array($name, $this->obsoleteProperties)) {
|
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
trigger_error('Undefined property: ' . get_class($this) . '::$' . $name, E_USER_NOTICE);
|
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)
|
public function __set($name, $value)
|
||||||
{
|
{
|
||||||
$allowed = array('template_dir' => 'setTemplateDir', 'config_dir' => 'setConfigDir',
|
if (isset(self::$accessMap[$name])) {
|
||||||
'plugins_dir' => 'setPluginsDir', 'compile_dir' => 'setCompileDir',
|
$this->{self::$accessMap[$name]}($value);
|
||||||
'cache_dir' => 'setCacheDir',);
|
} elseif (in_array($name, self::$obsoleteProperties)) {
|
||||||
|
|
||||||
if (isset($allowed[$name])) {
|
|
||||||
$this->{$allowed[$name]}($value);
|
|
||||||
} elseif (in_array($name, $this->obsoleteProperties)) {
|
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
if (is_object($value) && method_exists($value, $name)) {
|
if (is_object($value) && method_exists($value, $name)) {
|
||||||
|
@@ -53,13 +53,6 @@ class Smarty_Internal_Data
|
|||||||
*/
|
*/
|
||||||
public $config_vars = array();
|
public $config_vars = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* universal cache
|
|
||||||
*
|
|
||||||
* @var array()
|
|
||||||
*/
|
|
||||||
public $_cache = array();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cache for property information from generic getter/setter
|
* Cache for property information from generic getter/setter
|
||||||
* Preloaded with names which should not use with 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)
|
public function __call($name, $args)
|
||||||
{
|
{
|
||||||
static $_resolved_property_name = array();
|
$smarty = $this->_objType == 1 ? $this : $this->smarty;
|
||||||
|
if (!isset($smarty->_cache['extObjCache'][$name])) {
|
||||||
if (!isset(Smarty::$extObjCache[$name])) {
|
|
||||||
|
|
||||||
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
$class = 'Smarty_Internal_Method_' . ucfirst($name);
|
||||||
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
if (preg_match('/^(set|get)([A-Z].*)$/', $name, $match)) {
|
||||||
if (!isset($this->_property_info[$prop = $match[2]])) {
|
if (!isset($this->_property_info[$prop = $match[2]])) {
|
||||||
$smarty = isset($this->smarty) ? $this->smarty : $this;
|
|
||||||
if (!isset($this->_property_info[$prop])) {
|
if (!isset($this->_property_info[$prop])) {
|
||||||
// convert camel case to underscored name
|
// 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)));
|
PREG_SPLIT_DELIM_CAPTURE)));
|
||||||
$this->_property_info[$prop] = property_exists($this, $pn) ? 1 : ($this->_objType == 2 &&
|
$this->_property_info[$prop] = property_exists($this, $pn) ? 1 : ($this->_objType == 2 &&
|
||||||
property_exists($smarty, $pn) ? 2 : 0);
|
property_exists($smarty, $pn) ? 2 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($this->_property_info[$prop]) {
|
if ($this->_property_info[$prop]) {
|
||||||
$pn = $_resolved_property_name[$prop];
|
$pn = $smarty->_cache['resolvedProp'][$prop];
|
||||||
if ($match[1] == 'get') {
|
if ($match[1] == 'get') {
|
||||||
return $this->_property_info[$prop] == 1 ? $this->$pn : $this->smarty->$pn;
|
return $this->_property_info[$prop] == 1 ? $this->$pn : $this->smarty->$pn;
|
||||||
} else {
|
} else {
|
||||||
@@ -365,10 +356,10 @@ class Smarty_Internal_Data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (class_exists($class)) {
|
if (class_exists($class)) {
|
||||||
$callback = array(Smarty::$extObjCache[$name] = new $class(), $name);
|
$callback = array($smarty->_cache['extObjCache'][$name] = new $class(), $name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$callback = array(Smarty::$extObjCache[$name], $name);
|
$callback = array($smarty->_cache['extObjCache'][$name], $name);
|
||||||
}
|
}
|
||||||
if (isset($callback) && $callback[0]->objMap | $this->_objType) {
|
if (isset($callback) && $callback[0]->objMap | $this->_objType) {
|
||||||
array_unshift($args, $this);
|
array_unshift($args, $this);
|
||||||
|
@@ -74,6 +74,13 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
|||||||
*/
|
*/
|
||||||
public $cache_lifetime = 3600;
|
public $cache_lifetime = 3600;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* universal cache
|
||||||
|
*
|
||||||
|
* @var array()
|
||||||
|
*/
|
||||||
|
public $_cache = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fetches a rendered Smarty template
|
* fetches a rendered Smarty template
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user