- 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

View File

@@ -1,4 +1,8 @@
 ===== 3.1.22-dev ===== (xx.xx.2015)  ===== 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 20.03.2015
- bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452} - 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) - bugfix correct update of global variable values on exit of template functions. (reported under Smarty Developers)

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.22-dev/16'; const SMARTY_VERSION = '3.1.22-dev/17';
/** /**
* define variable scopes * define variable scopes

View File

@@ -564,14 +564,12 @@ class Smarty_Internal_Template extends Smarty_Internal_TemplateBase
$function ($_smarty_tpl, $params); $function ($_smarty_tpl, $params);
return; return;
} }
if ($_smarty_tpl->caching) {
// try to load template function dynamically // try to load template function dynamically
if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function, $params, $nocache)) { if (Smarty_Internal_Function_Call_Handler::call($name, $_smarty_tpl, $function, $params, $nocache)) {
$function ($_smarty_tpl, $params); $function ($_smarty_tpl, $params);
return; return;
} }
} }
}
throw new SmartyException("Unable to find template function '{$name}'"); throw new SmartyException("Unable to find template function '{$name}'");
} }

View File

@@ -304,6 +304,19 @@ class Smarty_Template_Cached
$_template->properties['cache_lifetime'] = $_template->cache_lifetime; $_template->properties['cache_lifetime'] = $_template->cache_lifetime;
$_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true)); $_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
$content = Smarty_Internal_Extension_CodeFrame::create($_template, $content, 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); return $this->write($_template, $content);
} }