diff --git a/change_log.txt b/change_log.txt index 3914cbe6..2e770538 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,8 @@  ===== 3.1.22-dev ===== (xx.xx.2015) + 23.03.2015 + - bugfix problems when {function}{/function} defined a template function in a cached subtemplate and it was called {call} + from a not cached subtemplate {forum topic 25468} + 20.03.2015 - bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 01b814bc..d4e50af4 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.22-dev/16'; + const SMARTY_VERSION = '3.1.22-dev/17'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_template.php b/libs/sysplugins/smarty_internal_template.php index f34fa1d8..59fdae75 100644 --- a/libs/sysplugins/smarty_internal_template.php +++ b/libs/sysplugins/smarty_internal_template.php @@ -564,12 +564,10 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase $function ($_smarty_tpl, $params); return; } - if ($_smarty_tpl->caching) { - // try to load template function dynamically - if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function, $params, $nocache)) { - $function ($_smarty_tpl, $params); - return; - } + // try to load template function dynamically + if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function, $params, $nocache)) { + $function ($_smarty_tpl, $params); + return; } } throw new SmartyException("Unable to find template function '{$name}'"); diff --git a/libs/sysplugins/smarty_template_cached.php b/libs/sysplugins/smarty_template_cached.php index 721d6944..7824dc48 100644 --- a/libs/sysplugins/smarty_template_cached.php +++ b/libs/sysplugins/smarty_template_cached.php @@ -304,6 +304,19 @@ class Smarty_Template_Cached $_template->properties['cache_lifetime'] = $_template->cache_lifetime; $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); $content = Smarty_Internal_Extension_CodeFrame::create($_template, $content, true); + if (!empty($_template->properties['tpl_function'])) { + foreach ($_template->properties['tpl_function'] as $funcParam) { + if (is_file($funcParam['compiled_filepath'])) { + // read compiled file + $code = file_get_contents($funcParam['compiled_filepath']); + // grab template function + if (preg_match("/\/\* {$funcParam['call_name']} \*\/([\S\s]*?)\/\*\/ {$funcParam['call_name']} \*\//", $code, $match)) { + unset($code); + $content .= "\n"; + } + } + } + } return $this->write($_template, $content); }