mirror of
https://github.com/smarty-php/smarty.git
synced 2026-05-04 19:54:14 +02:00
- bugfix Smarty_Resource and Smarty_CacheResource runtime caching (Forum Post 75264)
www.smarty.net/forums/viewtopic.php?p=75264#75264
This commit is contained in:
@@ -18,14 +18,14 @@ abstract class Smarty_CacheResource {
|
||||
* cache for Smarty_CacheResource instances
|
||||
* @var array
|
||||
*/
|
||||
protected static $resources = array();
|
||||
public static $resources = array();
|
||||
|
||||
/**
|
||||
* resource types provided by the core
|
||||
* @var array
|
||||
*/
|
||||
protected static $sysplugins = array(
|
||||
'file' => true,
|
||||
'file' => true,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -148,25 +148,32 @@ abstract class Smarty_CacheResource {
|
||||
if (!isset($type)) {
|
||||
$type = $smarty->caching_type;
|
||||
}
|
||||
// try the instance cache
|
||||
if (isset(self::$resources[$type])) {
|
||||
// FIXME: rodneyrehm need to validate if cache resource may be used in given $smarty.
|
||||
return self::$resources[$type];
|
||||
|
||||
// try smarty's cache
|
||||
if (isset($smarty->_cacheresource_handlers[$type])) {
|
||||
return $smarty->_cacheresource_handlers[$type];
|
||||
}
|
||||
|
||||
// try registered resource
|
||||
if (isset($smarty->registered_cache_resources[$type])) {
|
||||
// do not cache these instances as they may vary from instance to instance
|
||||
return $smarty->registered_cache_resources[$type];
|
||||
return $smarty->_cacheresource_handlers[$type] = $smarty->registered_cache_resources[$type];
|
||||
}
|
||||
// try sysplugins dir
|
||||
if (isset(self::$sysplugins[$type])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
return self::$resources[$type] = new $cache_resource_class();
|
||||
if (!isset(self::$resources[$type])) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
self::$resources[$type] = new $cache_resource_class();
|
||||
}
|
||||
return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
|
||||
}
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
if ($smarty->loadPlugin($cache_resource_class)) {
|
||||
return self::$resources[$type] = new $cache_resource_class();
|
||||
if (!isset(self::$resources[$type])) {
|
||||
self::$resources[$type] = new $cache_resource_class();
|
||||
}
|
||||
return $smarty->_cacheresource_handlers[$type] = self::$resources[$type];
|
||||
}
|
||||
// give up
|
||||
throw new SmartyException("Unable to load cache resource '{$type}'");
|
||||
|
||||
Reference in New Issue
Block a user