- 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}

This commit is contained in:
Uwe Tews
2015-03-23 00:39:22 +01:00
parent 2a005ac6d6
commit 443ae8c216
4 changed files with 22 additions and 7 deletions
+4 -6
View File
@@ -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}'");
@@ -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 .= "<?php " . $match[0] . "?>\n";
}
}
}
}
return $this->write($_template, $content);
}