From 6925c98af08e17f6cc59b356f65b70b9d77187e5 Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Thu, 12 Feb 2015 23:56:43 +0100 Subject: [PATCH] - bugfix multiple Smarty::fetch() of same template when $smarty->merge_compiled_includes = true; could cause function alreday defined error --- change_log.txt | 5 ++++- libs/sysplugins/smarty_internal_extension_codeframe.php | 6 ++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/change_log.txt b/change_log.txt index a86eea0c..99440d72 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,9 @@  ===== 3.1.22-dev ===== (xx.xx.2015) + 12.02.2015 + - bugfix multiple Smarty::fetch() of same template when $smarty->merge_compiled_includes = true; could cause function alreday defined error + 11.02.2015 - - bugfix recursive {includes} did create E_NOTICE message when $smarty->$merge_compiled_includes = true; (github issue #16) + - bugfix recursive {includes} did create E_NOTICE message when $smarty->merge_compiled_includes = true; (github issue #16) 22.01.2015 - new feature security can now control access to static methods and properties diff --git a/libs/sysplugins/smarty_internal_extension_codeframe.php b/libs/sysplugins/smarty_internal_extension_codeframe.php index fbf05563..4f5c557a 100644 --- a/libs/sysplugins/smarty_internal_extension_codeframe.php +++ b/libs/sysplugins/smarty_internal_extension_codeframe.php @@ -39,7 +39,8 @@ class Smarty_Internal_Extension_CodeFrame } $output .= "\$_valid = \$_smarty_tpl->decodeProperties(" . var_export($_template->properties, true) . ',' . ($cache ? 'true' : 'false') . ");\n"; $output .= "/*/%%SmartyHeaderCode%%*/\n"; - $output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n"; + $output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {\n"; + $output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n"; // include code for plugins if (!$cache) { if (!empty($_template->required_plugins['compiled'])) { @@ -82,11 +83,12 @@ class Smarty_Internal_Extension_CodeFrame } $output = "properties['nocache_hash']}%%*/\n"; + $output .= "if (\$_valid && !is_callable('{$_template->properties['unifunc']}')) {\n"; $output .= "function {$_template->properties['unifunc']} (\$_smarty_tpl) {\n"; $output .= "?>\n" . $content; $output .= "properties['nocache_hash']}%%*/\n"; - $output .= "}\n?>"; + $output .= "}\n}\n?>"; return $output; } } \ No newline at end of file