mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
- bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls
https://github.com/smarty-php/smarty/issues/301
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
===== 3.1.31-dev ===== (xx.xx.xx)
|
||||
27.10.2016
|
||||
- bugfix template function definitions array has not been cached between Smarty::fetch() and Smarty::display() calls
|
||||
https://github.com/smarty-php/smarty/issues/301
|
||||
|
||||
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
|
||||
- bugfix for compile locking touched timestamp of old compiled file was not restored on compilation error https://github.com/smarty-php/smarty/issues/308
|
||||
|
||||
|
@@ -114,7 +114,7 @@ class Smarty extends Smarty_Internal_TemplateBase
|
||||
/**
|
||||
* smarty version
|
||||
*/
|
||||
const SMARTY_VERSION = '3.1.31-dev/39';
|
||||
const SMARTY_VERSION = '3.1.31-dev/40';
|
||||
|
||||
/**
|
||||
* define variable scopes
|
||||
|
@@ -22,14 +22,16 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
*/
|
||||
public function callTemplateFunction(Smarty_Internal_Template $tpl, $name, $params, $nocache)
|
||||
{
|
||||
if (isset($tpl->tplFunctions[ $name ])) {
|
||||
$funcParam = isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : null);
|
||||
if (isset($funcParam)) {
|
||||
if (!$tpl->caching || ($tpl->caching && $nocache)) {
|
||||
$function = $tpl->tplFunctions[ $name ][ 'call_name' ];
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
} else {
|
||||
if (isset($tpl->tplFunctions[ $name ][ 'call_name_caching' ])) {
|
||||
$function = $tpl->tplFunctions[ $name ][ 'call_name_caching' ];
|
||||
if (isset($funcParam[ 'call_name_caching' ])) {
|
||||
$function = $funcParam[ 'call_name_caching' ];
|
||||
} else {
|
||||
$function = $tpl->tplFunctions[ $name ][ 'call_name' ];
|
||||
$function = $funcParam[ 'call_name' ];
|
||||
}
|
||||
}
|
||||
if (function_exists($function)) {
|
||||
@@ -52,23 +54,27 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
/**
|
||||
* Register template functions defined by template
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl
|
||||
* @param array $tplFunctions source information array of template functions defined in template
|
||||
* @param bool $override if true replace existing functions with same name
|
||||
* @param \Smarty|\Smarty_Internal_Template|\Smarty_Internal_TemplateBase $obj
|
||||
* @param array $tplFunctions source information array of template functions defined in template
|
||||
* @param bool $override if true replace existing functions with same name
|
||||
*/
|
||||
public function registerTplFunctions(Smarty_Internal_Template $tpl, $tplFunctions, $override = true)
|
||||
public function registerTplFunctions(Smarty_Internal_TemplateBase $obj, $tplFunctions, $override = true)
|
||||
{
|
||||
$tpl->tplFunctions = $override ? array_merge($tpl->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $tpl->tplFunctions);
|
||||
$obj->tplFunctions =
|
||||
$override ? array_merge($obj->tplFunctions, $tplFunctions) : array_merge($tplFunctions, $obj->tplFunctions);
|
||||
// make sure that the template functions are known in parent templates
|
||||
if ($tpl->_isSubTpl()) {
|
||||
$tpl->smarty->ext->_tplFunction->registerTplFunctions($tpl->parent,$tplFunctions, false);
|
||||
if ($obj->_isSubTpl()) {
|
||||
$obj->smarty->ext->_tplFunction->registerTplFunctions($obj->parent, $tplFunctions, false);
|
||||
} else {
|
||||
$obj->smarty->tplFunctions = $override ? array_merge($obj->smarty->tplFunctions, $tplFunctions) :
|
||||
array_merge($tplFunctions, $obj->smarty->tplFunctions);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return source parameter array for single or all template functions
|
||||
*
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param \Smarty_Internal_Template $tpl template object
|
||||
* @param null|string $name template function name
|
||||
*
|
||||
* @return array|bool|mixed
|
||||
@@ -76,9 +82,10 @@ class Smarty_Internal_Runtime_TplFunction
|
||||
public function getTplFunction(Smarty_Internal_Template $tpl, $name = null)
|
||||
{
|
||||
if (isset($name)) {
|
||||
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] : false;
|
||||
return isset($tpl->tplFunctions[ $name ]) ? $tpl->tplFunctions[ $name ] :
|
||||
(isset($tpl->smarty->tplFunctions[ $name ]) ? $tpl->smarty->tplFunctions[ $name ] : false);
|
||||
} else {
|
||||
return $tpl->tplFunctions;
|
||||
return empty($tpl->tplFunctions) ? $tpl->smarty->tplFunctions : $tpl->tplFunctions;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -81,13 +81,6 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
|
||||
*/
|
||||
public $scope = 0;
|
||||
|
||||
/**
|
||||
* Array of source information for known template functions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $tplFunctions = array();
|
||||
|
||||
/**
|
||||
* Flag which is set while rending a cache file
|
||||
*
|
||||
|
@@ -76,6 +76,13 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
|
||||
*/
|
||||
public $cache_lifetime = 3600;
|
||||
|
||||
/**
|
||||
* Array of source information for known template functions
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $tplFunctions = array();
|
||||
|
||||
/**
|
||||
* universal cache
|
||||
*
|
||||
|
Reference in New Issue
Block a user