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)
This commit is contained in:
Franky Van Liedekerke 2020-12-03 22:59:13 +01:00 committed by Deon George
parent 45aa1e5208
commit 46cc4a1b13

View File

@ -139,16 +139,23 @@ class TemplateRender extends PageRender {
return;
}
if (!empty($args[0]))
$function_args = explode(',',$args[0]);
else
$function_args = '';
if (function_exists($function))
if (function_exists($function)) {
if (empty($function_args))
$vals = call_user_func($function);
else
$vals = call_user_func_array($function,$function_args);
else
} else {
system_message(array(
'title'=>_('Function doesnt exist'),
'body'=>sprintf('%s (<b>%s</b>)',_('An attempt was made to call a function that doesnt exist'),$function),
'type'=>'warn'));
}
break;