diff options
| author | uwe.tews@googlemail.com <uwe.tews@googlemail.com> | 2011-09-20 19:12:51 +0000 |
|---|---|---|
| committer | uwe.tews@googlemail.com <uwe.tews@googlemail.com> | 2011-09-20 19:12:51 +0000 |
| commit | eb60692dbe116d9e1050468020c5ce5198f61e68 (patch) | |
| tree | f0d36f66c3c65cd016923f6dcdaeb9fa5904c91b | |
| parent | a3dc61542d63d9c237259f757f48a115e2603dc5 (diff) | |
| download | smarty-eb60692dbe116d9e1050468020c5ce5198f61e68.tar.gz smarty-eb60692dbe116d9e1050468020c5ce5198f61e68.tar.bz2 smarty-eb60692dbe116d9e1050468020c5ce5198f61e68.zip | |
- bugfix {assign} with scope root and global did not work in all cases
| -rw-r--r-- | change_log.txt | 1 | ||||
| -rw-r--r-- | libs/sysplugins/smarty_internal_compile_assign.php | 12 |
2 files changed, 9 insertions, 4 deletions
diff --git a/change_log.txt b/change_log.txt index ab03140d..90549c0c 100644 --- a/change_log.txt +++ b/change_log.txt @@ -3,6 +3,7 @@ - bugfix removed debug echo output while compiling template inheritance - bugfix relative paths in $template_dir broke relative path resolving in {include "../foo.tpl"} - bugfix {include} did not work inside nested {block} tags +- bugfix {assign} with scope root and global did not work in all cases 19.09.2011 - bugfix regression in Smarty_CacheReource_KeyValueStore introduced by r4261 diff --git a/libs/sysplugins/smarty_internal_compile_assign.php b/libs/sysplugins/smarty_internal_compile_assign.php index 3cc3e144..40e46862 100644 --- a/libs/sysplugins/smarty_internal_compile_assign.php +++ b/libs/sysplugins/smarty_internal_compile_assign.php @@ -60,11 +60,15 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase { } else { $output = "<?php \$_smarty_tpl->tpl_vars[$_attr[var]] = new Smarty_variable($_attr[value], $_nocache, $_scope);"; } - if ($_scope != Smarty::SCOPE_LOCAL) { - $output .= "\nif (\$tmp_ptr = &\$_smarty_tpl->getScope($_scope) != null) \$tmp_ptr[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];?>"; - } else { - $output .= '?>'; + if ($_scope == Smarty::SCOPE_PARENT) { + $output .= "\nif (\$_smarty_tpl->parent != null) \$_smarty_tpl->parent->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];"; + } elseif ($_scope == Smarty::SCOPE_ROOT || $_scope == Smarty::SCOPE_GLOBAL) { + $output .= "\n\$_ptr = \$_smarty_tpl->parent; while (\$_ptr != null) {\$_ptr->tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]]; \$_ptr = \$_ptr->parent; }"; + } + if ( $_scope == Smarty::SCOPE_GLOBAL) { + $output .= "\nSmarty::\$global_tpl_vars[$_attr[var]] = clone \$_smarty_tpl->tpl_vars[$_attr[var]];"; } + $output .= '?>'; return $output; } |
