mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827)
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
===== 3.1.29-dev ===== (xx.xx.2015)
|
===== 3.1.29-dev ===== (xx.xx.2015)
|
||||||
17.12.2015
|
17.12.2015
|
||||||
- bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135
|
- bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135
|
||||||
|
- bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827)
|
||||||
16.12.2015
|
16.12.2015
|
||||||
- bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128
|
- bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128
|
||||||
- bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121
|
- bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121
|
||||||
|
@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
|||||||
/**
|
/**
|
||||||
* smarty version
|
* smarty version
|
||||||
*/
|
*/
|
||||||
const SMARTY_VERSION = '3.1.29-dev/8';
|
const SMARTY_VERSION = '3.1.29-dev/9';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* define variable scopes
|
* define variable scopes
|
||||||
|
@@ -142,7 +142,7 @@ class Smarty_Internal_Compile_Block extends Smarty_Internal_Compile_Shared_Inher
|
|||||||
}
|
}
|
||||||
$compiler->suppressNocacheProcessing = true;
|
$compiler->suppressNocacheProcessing = true;
|
||||||
$compiler->has_code = true;
|
$compiler->has_code = true;
|
||||||
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 3, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
$output = "<?php \n\$_smarty_tpl->ext->_inheritance->processBlock(\$_smarty_tpl, 4, {$compiler->_cache['blockName'][$compiler->_cache['blockNesting']]}, null, \$_blockParentStack);\n?>\n";
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -127,8 +127,11 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
* - search in inheritance template hierarchy for child blocks
|
* - search in inheritance template hierarchy for child blocks
|
||||||
* if found call it, otherwise ignore
|
* if found call it, otherwise ignore
|
||||||
*
|
*
|
||||||
* $type 3 = {$smarty.block.parent}:
|
* $type 3 = {block append} {block prepend}:
|
||||||
* - get block id from parent stack and call parent block
|
* - call parent block
|
||||||
|
*
|
||||||
|
* $type 4 = {$smarty.block.parent}:
|
||||||
|
* - call parent block
|
||||||
*
|
*
|
||||||
* @param \Smarty_Internal_Template $tpl template object of caller
|
* @param \Smarty_Internal_Template $tpl template object of caller
|
||||||
* @param int $type call type see above
|
* @param int $type call type see above
|
||||||
@@ -150,6 +153,12 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ($type == 3) {
|
if ($type == 3) {
|
||||||
|
if (!empty($callStack)) {
|
||||||
|
$block = array_shift($callStack);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} elseif ($type == 4) {
|
||||||
if (!empty($callStack)) {
|
if (!empty($callStack)) {
|
||||||
array_shift($callStack);
|
array_shift($callStack);
|
||||||
if (empty($callStack)) {
|
if (empty($callStack)) {
|
||||||
@@ -160,6 +169,7 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
$index = 0;
|
||||||
$blockParameter = &$this->blockParameter[ $name ];
|
$blockParameter = &$this->blockParameter[ $name ];
|
||||||
if ($type == 0) {
|
if ($type == 0) {
|
||||||
$index = $block[ 2 ] = count($blockParameter);
|
$index = $block[ 2 ] = count($blockParameter);
|
||||||
@@ -167,7 +177,6 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
$callStack = array(&$block);
|
$callStack = array(&$block);
|
||||||
} elseif ($type == 1) {
|
} elseif ($type == 1) {
|
||||||
$block[ 3 ] = $callStack[ 0 ][ 3 ];
|
$block[ 3 ] = $callStack[ 0 ][ 3 ];
|
||||||
$index = 0;
|
|
||||||
for ($i = 0; $i < count($blockParameter); $i ++) {
|
for ($i = 0; $i < count($blockParameter); $i ++) {
|
||||||
if ($blockParameter[ $i ][ 3 ] <= $block[ 3 ]) {
|
if ($blockParameter[ $i ][ 3 ] <= $block[ 3 ]) {
|
||||||
$index = $blockParameter[ $i ][ 2 ];
|
$index = $blockParameter[ $i ][ 2 ];
|
||||||
@@ -175,7 +184,7 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
}
|
}
|
||||||
$block[ 2 ] = $index;
|
$block[ 2 ] = $index;
|
||||||
$callStack = array(&$block);
|
$callStack = array(&$block);
|
||||||
} else {
|
} elseif ($type == 2) {
|
||||||
$index = $callStack[ 0 ][ 2 ];
|
$index = $callStack[ 0 ][ 2 ];
|
||||||
if ($index == 0) {
|
if ($index == 0) {
|
||||||
return;
|
return;
|
||||||
@@ -197,16 +206,23 @@ class Smarty_Internal_Runtime_Inheritance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->blockNesting ++;
|
$this->blockNesting ++;
|
||||||
|
// {block append} ?
|
||||||
if (isset($block[ 'append' ])) {
|
if (isset($block[ 'append' ])) {
|
||||||
$this->processBlock($tpl, 3, $name, null, $callStack);
|
$appendStack = $callStack;
|
||||||
|
if ($type == 0) {
|
||||||
|
array_shift($appendStack);
|
||||||
}
|
}
|
||||||
if (isset($block[6])) {
|
$this->processBlock($tpl, 3, $name, null, $appendStack);
|
||||||
$block[6]($tpl, $callStack);
|
}
|
||||||
} else {
|
// call block of current stack level
|
||||||
$block[ 0 ]($tpl, $callStack);
|
$block[ 0 ]($tpl, $callStack);
|
||||||
}
|
// {block prepend} ?
|
||||||
if (isset($block[ 'prepend' ])) {
|
if (isset($block[ 'prepend' ])) {
|
||||||
$this->processBlock($tpl, 3, $name, null, $callStack);
|
$prependStack = $callStack;
|
||||||
|
if ($type == 0) {
|
||||||
|
array_shift($prependStack);
|
||||||
|
}
|
||||||
|
$this->processBlock($tpl, 3, $name, null, $prependStack);
|
||||||
}
|
}
|
||||||
$this->blockNesting --;
|
$this->blockNesting --;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user