- 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

This commit is contained in:
uwetews
2016-03-27 18:44:19 +02:00
parent ff6a8521bb
commit 2dac1729c2
4 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,7 @@
 ===== 3.1.30-dev ===== (xx.xx.xx)  ===== 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 11.03.2014
- optimization of capture and security handling - optimization of capture and security handling
- improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources - improvement $smarty->clearCompiledTemplate() should return on recompiled or uncompiled resources

View File

@@ -121,7 +121,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.30-dev/57'; const SMARTY_VERSION = '3.1.30-dev/59';
/** /**
* define variable scopes * 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 * @param string $compile_dir directory to store compiled templates in
* *

View File

@@ -51,7 +51,7 @@ class Smarty_Internal_Compile_Capture extends Smarty_Internal_CompileBase
if (!$name) { if (!$name) {
$compiler->trigger_template_error("missing or illegal \$smarty.{$tag} name attribute", null, true); $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); $compiler->_cache[ 'capture_stack' ][] = array($compiler->nocache);
// maybe nocache because of nocache variables // maybe nocache because of nocache variables
$compiler->nocache = $compiler->nocache | $compiler->tag_nocache; $compiler->nocache = $compiler->nocache | $compiler->tag_nocache;
$_output = "<?php \$_smarty_tpl->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);\n?>\n"; $_output = "<?php \$_smarty_tpl->smarty->ext->_capture->open(\$_smarty_tpl, $buffer, $assign, $append);\n?>\n";
return $_output; return $_output;
} }
@@ -109,6 +109,6 @@ class Smarty_Internal_Compile_CaptureClose extends Smarty_Internal_CompileBase
list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]); list($compiler->nocache) = array_pop($compiler->_cache[ 'capture_stack' ]);
return "<?php \$_smarty_tpl->ext->_capture->close(\$_smarty_tpl);\n?>\n"; return "<?php \$_smarty_tpl->smarty->ext->_capture->close(\$_smarty_tpl);\n?>\n";
} }
} }

View File

@@ -37,6 +37,13 @@ class Smarty_Internal_Runtime_Capture
*/ */
private $countStack = array(); private $countStack = array();
/**
* Named buffer
*
* @var string[]
*/
private $namedBuffer = array();
/** /**
* Flag if callbacks are registered * Flag if callbacks are registered
* *
@@ -84,7 +91,6 @@ class Smarty_Internal_Runtime_Capture
{ {
$this->countStack[] = $this->captureCount; $this->countStack[] = $this->captureCount;
$this->captureCount = 0; $this->captureCount = 0;
$_template->_cache[ 'capture' ] = array();
} }
/** /**
@@ -105,7 +111,7 @@ class Smarty_Internal_Runtime_Capture
if (isset($append)) { if (isset($append)) {
$_template->append($append, ob_get_contents()); $_template->append($append, ob_get_contents());
} }
$_template->_cache[ 'capture' ][ $buffer ] = ob_get_clean(); $this->namedBuffer[ $buffer ] = ob_get_clean();
} else { } else {
$this->error($_template); $this->error($_template);
} }
@@ -133,7 +139,7 @@ class Smarty_Internal_Runtime_Capture
*/ */
public function getBuffer(Smarty_Internal_Template $_template, $name) 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;
} }
/** /**