- bugfix make sure that function properties get saved only in compiled files containing the fuction definition {forum topic 25452}

This commit is contained in:
Uwe Tews
2015-03-20 00:41:55 +01:00
parent 03c7b786a0
commit 4ecc75344f
4 changed files with 12 additions and 5 deletions
@@ -32,12 +32,19 @@ class Smarty_Internal_Extension_CodeFrame
if (!isset($_template->properties['unifunc'])) {
$_template->properties['unifunc'] = 'content_' . str_replace(array('.', ','), '_', uniqid('', true));
}
$properties = $_template->properties;
if (!$cache) {
unset($properties['tpl_function']);
if (!empty($_template->compiler->templateProperties)) {
$properties['tpl_function'] = $_template->compiler->templateProperties['tpl_function'];
}
}
$output = "<?php\n";
$output .= "/*%%SmartyHeaderCode:{$_template->properties['nocache_hash']}%%*/\n";
if ($_template->smarty->direct_access_security) {
$output .= "if(!defined('SMARTY_DIR')) exit('no direct access allowed');\n";
}
$output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($_template->properties, true) . ',' . ($cache ? 'true' : 'false') . ");\n";
$output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($properties, true) . ',' . ($cache ? 'true' : 'false') . ");\n";
$output .= "/*/%%SmartyHeaderCode%%*/\n";
$output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {\n";
$output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n";