From 46cc4a1b138c0a28bdabb5e58ab058a64952f405 Mon Sep 17 00:00:00 2001 From: Franky Van Liedekerke Date: Thu, 3 Dec 2020 22:59:13 +0100 Subject: [PATCH] Take into account empty arguments If no argument is given to the function call, don't try to pass an empty array as some php functions don't allow arguments (like the time function) --- lib/TemplateRender.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/TemplateRender.php b/lib/TemplateRender.php index 22126b7..a9f2649 100644 --- a/lib/TemplateRender.php +++ b/lib/TemplateRender.php @@ -139,16 +139,23 @@ class TemplateRender extends PageRender { return; } - $function_args = explode(',',$args[0]); - - if (function_exists($function)) - $vals = call_user_func_array($function,$function_args); - + if (!empty($args[0])) + $function_args = explode(',',$args[0]); else + $function_args = ''; + + if (function_exists($function)) { + if (empty($function_args)) + $vals = call_user_func($function); + else + $vals = call_user_func_array($function,$function_args); + + } else { system_message(array( 'title'=>_('Function doesnt exist'), 'body'=>sprintf('%s (%s)',_('An attempt was made to call a function that doesnt exist'),$function), 'type'=>'warn')); + } break;