From 2dac1729c28d0dbab7dea3dd52ce9f780b35f876 Mon Sep 17 00:00:00 2001 From: uwetews Date: Sun, 27 Mar 2016 18:44:19 +0200 Subject: [PATCH] - bugfix change of 11.03.2014 cause again {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 --- change_log.txt | 3 +++ libs/Smarty.class.php | 3 +-- libs/sysplugins/smarty_internal_compile_capture.php | 6 +++--- libs/sysplugins/smarty_internal_runtime_capture.php | 12 +++++++++--- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/change_log.txt b/change_log.txt index 91aec313..84ddfdf0 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.30-dev ===== (xx.xx.xx) + 27.03.2014 + - bugfix change of 11.03.2014 cause again {capture} data could not been seen in other templates with {$smarty.capture.name} https://github.com/smarty-php/smarty/issues/153 + 11.03.2014 - optimization of capture and security handling - improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index d6098fd2..9ba0c060 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/57'; + const SMARTY_VERSION = '3.1.30-dev/59'; /** * define variable scopes @@ -922,7 +922,6 @@ class Smarty extends Smarty_Internal_TemplateBase } /** - * Set compile directory * * @param string $compile_dir directory to store compiled templates in * diff --git a/libs/sysplugins/smarty_internal_compile_capture.php b/libs/sysplugins/smarty_internal_compile_capture.php index e0bac311..7b1080ae 100644 --- a/libs/sysplugins/smarty_internal_compile_capture.php +++ b/libs/sysplugins/smarty_internal_compile_capture.php @@ -51,7 +51,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase if (!$name) { $compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true); } - return "\$_smarty_tpl->ext->_capture->getBuffer(\$_smarty_tpl, '{$name}')"; + return "\$_smarty_tpl->smarty->ext->_capture->getBuffer(\$_smarty_tpl, '{$name}')"; } /** @@ -75,7 +75,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase $compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache); // maybe nocache because of nocache variables $compiler->nocache = $compiler->nocache | $compiler->tag_nocache; - $_output = "ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);\n?>\n"; + $_output = "smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);\n?>\n"; return $_output; } @@ -109,6 +109,6 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]); - return "ext->_capture->close(\$_smarty_tpl);\n?>\n"; + return "smarty->ext->_capture->close(\$_smarty_tpl);\n?>\n"; } } diff --git a/libs/sysplugins/smarty_internal_runtime_capture.php b/libs/sysplugins/smarty_internal_runtime_capture.php index e1ccfffe..69f1ce0c 100644 --- a/libs/sysplugins/smarty_internal_runtime_capture.php +++ b/libs/sysplugins/smarty_internal_runtime_capture.php @@ -37,6 +37,13 @@ class Smarty_Internal_Runtime_Capture */ private $countStack = array(); + /** + * Named buffer + * + * @var string[] + */ + private $namedBuffer = array(); + /** * Flag if callbacks are registered * @@ -84,7 +91,6 @@ class Smarty_Internal_Runtime_Capture { $this->countStack[] = $this->captureCount; $this->captureCount = 0; - $_template->_cache[ 'capture' ] = array(); } /** @@ -105,7 +111,7 @@ class Smarty_Internal_Runtime_Capture if (isset($append)) { $_template->append($append, ob_get_contents()); } - $_template->_cache[ 'capture' ][ $buffer ] = ob_get_clean(); + $this->namedBuffer[ $buffer ] = ob_get_clean(); } else { $this->error($_template); } @@ -133,7 +139,7 @@ class Smarty_Internal_Runtime_Capture */ public function getBuffer(Smarty_Internal_Template $_template, $name) { - return isset($_template->_cache[ 'capture' ][ $name ]) ? $_template->_cache[ 'capture' ][ $name ] : null; + return isset($this->namedBuffer[ $name ]) ? $this->namedBuffer[ $name ] : null; } /**