From e1bf16a504eb1d5059941cc14a8616890b6cf875 Mon Sep 17 00:00:00 2001 From: uwetews Date: Fri, 29 Jan 2016 01:21:00 +0100 Subject: [PATCH] - bugfix implement replacement code for _tag_stack property https://github.com/smarty-php/smarty/issues/151 --- change_log.txt | 3 +++ libs/Smarty.class.php | 5 +++-- .../smarty_internal_compile_private_block_plugin.php | 7 +++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/change_log.txt b/change_log.txt index c13678c9..cf4869bb 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) + 29.01.2016 + - bugfix implement replacement code for _tag_stack property https://github.com/smarty-php/smarty/issues/151 + 28.01.2016 - bugfix allow windows network filepath or wrapper (forum topic 25876) https://github.com/smarty-php/smarty/issues/170 - bugfix if fetch('foo.tpl') is called on a template object the $parent parameter should default to the calling template object https://github.com/smarty-php/smarty/issues/152 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 0666d01e..7c447068 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.30-dev/27'; + const SMARTY_VERSION = '3.1.30-dev/28'; /** * define variable scopes @@ -1319,10 +1319,11 @@ class Smarty extends Smarty_Internal_TemplateBase */ public function __get($name) { - if (isset($this->accessMap[ $name ])) { $method = 'get' . $this->accessMap[ $name ]; return $this->{$method}(); + } elseif (isset($this->_cache[ $name ])) { + return $this->_cache[ $name ]; } elseif (in_array($name, $this->obsoleteProperties)) { return null; } else { diff --git a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php index 4910b72f..30f5d1cf 100644 --- a/libs/sysplugins/smarty_internal_compile_private_block_plugin.php +++ b/libs/sysplugins/smarty_internal_compile_private_block_plugin.php @@ -65,12 +65,13 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi if (isset($callable)) { $output .= "if (!is_callable({$callable})) {\nthrow new SmartyException('block tag \'{$tag}\' not callable or registered');\n}\n"; } + $output .= "\$_smarty_tpl->smarty->_cache['_tag_stack'][] = array('{$tag}', {$_params});\n"; $output .= "\$_block_repeat{$this->nesting}=true;\necho {$callback}({$_params}, null, \$_smarty_tpl, \$_block_repeat{$this->nesting});\nwhile (\$_block_repeat{$this->nesting}) {\nob_start();\n?>"; $this->openTag($compiler, $tag, array($_params, $compiler->nocache, $callback)); // maybe nocache because of nocache variables or nocache plugin $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; - } else { + } else { // must endblock be nocache? if ($compiler->nocache) { $compiler->tag_nocache = true; @@ -93,7 +94,9 @@ class Smarty_Internal_Compile_Private_Block_Plugin extends Smarty_Internal_Compi } $output = "nesting}=false;\n" . $mod_pre . "echo {$callback}({$_params}, " . $mod_content2 . - ", \$_smarty_tpl, \$_block_repeat{$this->nesting});\n" . $mod_post . "}\n?>"; + ", \$_smarty_tpl, \$_block_repeat{$this->nesting});\n" . $mod_post . "}\n"; + $output .= "array_pop(\$_smarty_tpl->smarty->_cache['_tag_stack']);"; + $output .= "?>"; $this->nesting --; } return $output . "\n";