diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index e50f877c..b16b84b3 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -1315,23 +1315,9 @@ class Smarty extends Smarty_Internal_TemplateBase } else { $data = null; } - $_templateId = $this->getTemplateId($template, $cache_id, $compile_id); - if (isset($this->template_objects[$_templateId])) { - if ($do_clone) { - $tpl = clone $this->template_objects[$_templateId]; - $tpl->smarty = clone $tpl->smarty; - } else { - $tpl = $this->template_objects[$_templateId]; - } - $tpl->parent = $parent; - $tpl->tpl_vars = array(); - $tpl->config_vars = array(); - } else { - $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); - if ($do_clone) { - $tpl->smarty = clone $tpl->smarty; - } - $tpl->templateId = $_templateId; + $tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id); + if ($do_clone) { + $tpl->smarty = clone $tpl->smarty; } // fill data if present if (!empty($data) && is_array($data)) { @@ -1610,7 +1596,7 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function __destruct() { - $i =0;// intentionally left blank + $i = 0;// intentionally left blank } /** diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index 4a796fa0..34d2d5a1 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -41,13 +41,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase */ public $template_resource = null; - /** - * Saved template Id - * - * @var null|string - */ - public $templateId = null; - /** * flag if compiled template is invalid and must be (re)compiled * @@ -494,22 +487,28 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase */ public function setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope) { - $_templateId = $this->getTemplateId($template, $cache_id, $compile_id); - // already in template cache? - if (isset($this->smarty->template_objects[$_templateId])) { - // clone cached template object because of possible recursive call - $tpl = clone $this->smarty->template_objects[$_templateId]; - $tpl->parent = $this; - if ((bool) $tpl->caching !== (bool) $caching) { - unset($tpl->compiled); + $tpl = $_templateId = null; + if ($this->smarty->template_resource_caching) { + $_templateId = $this->getTemplateId($template, $cache_id, $compile_id); + // already in template cache? + if (isset($this->smarty->template_objects[$_templateId])) { + // clone cached template object because of possible recursive call + $tpl = clone $this->smarty->template_objects[$_templateId]; + $tpl->parent = $this; + if ((bool) $tpl->caching !== (bool) $caching) { + unset($tpl->compiled); + } + $tpl->caching = $caching; + $tpl->cache_lifetime = $cache_lifetime; } - $tpl->caching = $caching; - $tpl->cache_lifetime = $cache_lifetime; - } else { - $tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime); - $tpl->templateId = $_templateId; } - // get variables from calling scope + if (!isset($tpl)) { + $tpl = new $this->smarty->template_class($template, $this->smarty, $this, $cache_id, $compile_id, $caching, $cache_lifetime); + if ($this->smarty->template_resource_caching && !$tpl->source->recompiled) { + $this->smarty->template_objects[$_templateId] = $tpl; + } + } + // get variables from calling scope if ($parent_scope == Smarty::SCOPE_LOCAL) { $tpl->tpl_vars = $this->tpl_vars; } elseif ($parent_scope == Smarty::SCOPE_PARENT) { @@ -551,9 +550,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase { $tpl = $this->setupSubTemplate($template, $cache_id, $compile_id, $caching, $cache_lifetime, $data, $parent_scope); $tpl->properties['nocache_hash'] = $hash; - if (!isset($this->smarty->template_objects[$tpl->templateId])) { - $this->smarty->template_objects[$tpl->templateId] = $tpl; - } if ($this->smarty->debugging) { Smarty_Internal_Debug::start_template($tpl); Smarty_Internal_Debug::start_render($tpl);