diff --git a/change_log.txt b/change_log.txt index 7346e7b0..2bc6d04a 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,7 @@ 13/11/2010 - bugfix overloading problem when $smarty->fetch()/display() have been used in plugins (introduced with 3.0.2) +- code cleanup ===== Smarty 3.0.3 ===== diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 96bfac73..0d478512 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -564,19 +564,15 @@ class Smarty extends Smarty_Internal_Data { if (!isset($type)) { $type = $this->caching_type; } - // already loaded? - if (isset($this->cache_resource_objects[$type])) { - return $this->cache_resource_objects[$type]; - } if (in_array($type, $this->cache_resource_types)) { $cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type); - return $this->cache_resource_objects[$type] = new $cache_resource_class($this); + return new $cache_resource_class($this); } else { // try plugins dir $cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type); - if (Smarty_Internal_Plugin_Loader::loadPlugin($cache_resource_class, $this->plugins_dir)) { - return $this->cache_resource_objects[$type] = new $cache_resource_class($this); + if ($this->loadPlugin($cache_resource_class)) { + return new $cache_resource_class($this); } else { throw new SmartyException("Unable to load cache resource '{$type}'"); diff --git a/libs/sysplugins/smarty_internal_debug.php b/libs/sysplugins/smarty_internal_debug.php index e9cf821c..d165d7d7 100644 --- a/libs/sysplugins/smarty_internal_debug.php +++ b/libs/sysplugins/smarty_internal_debug.php @@ -93,7 +93,7 @@ class Smarty_Internal_Debug extends Smarty_Internal_Data { $rdelim = $smarty->right_delimiter; $smarty->left_delimiter = '{'; $smarty->right_delimiter = '}'; - $_template = new Smarty_Template ($smarty->debug_tpl, $smarty); + $_template = new Smarty_Internal_Template ($smarty->debug_tpl, $smarty); $_template->caching = false; $_template->force_compile = false; $_template->disableSecurity(); diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index bf1fb2da..be20df41 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -95,7 +95,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { // Template resource $this->template_resource = $template_resource; // copy block data of template inheritance - if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) { + if ($this->parent instanceof Smarty_Internal_Template) { $this->block_data = $this->parent->block_data; } @@ -455,7 +455,7 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { if (!$this->resource_object->isEvaluated && empty($this->properties['file_dependency'][$this->templateUid])) { $this->properties['file_dependency'][$this->templateUid] = array($this->getTemplateFilepath(), $this->getTemplateTimestamp(),$this->resource_type); } - if ($this->parent instanceof Smarty_Template or $this->parent instanceof Smarty_Internal_Template) { + if ($this->parent instanceof Smarty_Internal_Template) { $this->parent->properties['file_dependency'] = array_merge($this->parent->properties['file_dependency'], $this->properties['file_dependency']); foreach($this->required_plugins as $code => $tmp1) { foreach($tmp1 as $name => $tmp) { @@ -859,7 +859,10 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { if ($template == null) { return $this->smarty->fetch($this); } else { - return $this->smarty->fetch($template, $cache_id, $compile_id, $parent, $display); + if (!isset($parent)) { + $parent = $this; + } + return $this->smarty->fetch($template, $cache_id, $compile_id, $parent, $display); } } @@ -872,6 +875,9 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { if ($template == null) { return $this->smarty->display($this); } else { + if (!isset($parent)) { + $parent = $this; + } return $this->smarty->display($template, $cache_id, $compile_id, $parent); } @@ -953,10 +959,4 @@ class Smarty_Internal_Template extends Smarty_Internal_Data { } } -/** - * wrapper for template class - */ -class Smarty_Template extends Smarty_Internal_Template { -} - ?> \ No newline at end of file