- improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property

should be copied to the called template object
This commit is contained in:
uwetews
2016-10-23 18:34:59 +02:00
parent 29cbe10857
commit d79edd2fe0
3 changed files with 15 additions and 3 deletions

View File

@@ -1,4 +1,8 @@
===== 3.1.31-dev ===== (xx.xx.xx) ===== 3.1.31-dev ===== (xx.xx.xx)
23.10.2016
- improvement/bugfix when Smarty::fetch() is called on a template object the inheritance and tplFunctions property
should be copied to the called template object
21.10.2016 21.10.2016
- bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308 - bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308

View File

@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.31-dev/38'; const SMARTY_VERSION = '3.1.31-dev/39';
/** /**
* define variable scopes * define variable scopes

View File

@@ -157,18 +157,26 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
$template = $this; $template = $this;
} }
} elseif (is_object($template)) { } elseif (is_object($template)) {
/* @var Smarty_Internal_Template $template */
if (!isset($template->_objType) || !$template->_isTplObj()) { if (!isset($template->_objType) || !$template->_isTplObj()) {
throw new SmartyException($function . '():Template object expected'); throw new SmartyException($function . '():Template object expected');
} }
} else { } else {
// get template object // get template object
/* @var Smarty_Internal_Template $template */
$saveVars = false; $saveVars = false;
$template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false); $template = $smarty->createTemplate($template, $cache_id, $compile_id, $parent ? $parent : $this, false);
if ($this->_objType == 1) { if ($this->_objType == 1) {
// set caching in template object // set caching in template object
$template->caching = $this->caching; $template->caching = $this->caching;
} else {
/* @var Smarty_Internal_Template $this */
$template->tplFunctions = $this->tplFunctions;
$template->inheritance = $this->inheritance;
}
/* @var Smarty_Internal_Template $parent */
if (isset($parent->_objType) && ($parent->_objType == 2) && !empty($parent->tplFunctions)) {
$template->tplFunctions = array_merge($parent->tplFunctions, $template->tplFunctions);
} }
} }
// fetch template content // fetch template content