diff --git a/change_log.txt b/change_log.txt index d17f592c..3cfd17ce 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,8 @@ +10/11/2009 +- fixed bug when template with same name is used with different data objects +- fixed bug with double quoted name attribute at {insert} tag +- reenabled assign_by_ref and append_by_ref methodes + 10/07/2009 - removed block nesting checks for {capture} diff --git a/libs/sysplugins/internal.compile_insert.php b/libs/sysplugins/internal.compile_insert.php index 9118ab01..765e8df2 100644 --- a/libs/sysplugins/internal.compile_insert.php +++ b/libs/sysplugins/internal.compile_insert.php @@ -32,7 +32,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase { $_output = 'assign($tpl_var, $value, $nocache, $scope); + if ($tpl_var != '') { + $this->check_tplvar($tpl_var); + $this->tpl_vars[$tpl_var] = new Smarty_variable(null, $nocache, $scope); + $this->tpl_vars[$tpl_var]->value = &$value; + } } /** * appends values to template variables @@ -133,11 +141,27 @@ class Smarty_Internal_TemplateBase { /** * appends values to template variables by reference * - * wrapper to append + * @param string $tpl_var the template variable name + * @param mixed $ &$value the referenced value to append + * @param boolean $merge flag if array elements shall be merged */ - public function append_by_ref($tpl_var, $value = null, $merge = false, $nocache = false, $scope = SMARTY_LOCAL_SCOPE) + public function append_by_ref($tpl_var, &$value, $merge = false) { - $this->append($tpl_var, $value, $merge, $nocache, $scope); + if ($tpl_var != '' && isset($value)) { + if (!isset($this->tpl_vars[$tpl_var])) { + $this->tpl_vars[$tpl_var] = new Smarty_variable(); + } + if (!@is_array($this->tpl_vars[$tpl_var]->value)) { + settype($this->tpl_vars[$tpl_var]->value, 'array'); + } + if ($merge && is_array($value)) { + foreach($value as $_key => $_val) { + $this->tpl_vars[$tpl_var]->value[$_key] = &$value[$_key]; + } + } else { + $this->tpl_vars[$tpl_var]->value[] = &$value; + } + } } /** @@ -282,11 +306,11 @@ class Smarty_Internal_TemplateBase { // we got a template resource $_templateId = $this->buildTemplateId ($template, $cache_id, $compile_id); // already in template cache? - if (isset($this->smarty->template_objects[$_templateId])) { + if (isset($this->smarty->template_objects[$_templateId]) && $this->smarty->caching) { // return cached template object $tpl = $this->smarty->template_objects[$_templateId]; } else { - // create and cache new template object + // create new template object $tpl = new $this->template_class($template, $this->smarty, $parent, $cache_id, $compile_id); } } else {