diff --git a/CHANGES.txt b/CHANGES.txt index 9b86139..e43a426 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,5 +1,8 @@ Change List ========= +Version 1.4.20(Build 202401xxxx) + - Added a try/catch to renderedcontent filter processing + Version 1.4.19(Build 2024012400) - Added a template and code to support it, that allows you to call a renderer function from a template diff --git a/filter.php b/filter.php index 59826b3..7f8a8e5 100644 --- a/filter.php +++ b/filter.php @@ -207,15 +207,21 @@ function filter_generico_callback(array $link) { //the args filterprops will be a pipe delimited string of args, eg {POODLL:type="mod_ogte",function="embed_table",args="arg1|arg2|arg3"} //if the args string contains "cloudpoodlltoken" it will be replaced with the actual cloud poodll token. if(isset($filterprops['renderer']) && isset($filterprops['function']) && strpos($filterprops['function'],'embed_')===0){ - if(!isset($token)){$token=false;} - $somerenderer = $PAGE->get_renderer($filterprops['renderer']); - $args=[]; - if(isset($filterprops['args'])){ - $args_string =str_replace('cloudpoodlltoken',$token,$filterprops['args']); - $args_array = explode('|',$args_string); - } - $renderedcontent=call_user_func_array([$somerenderer, $filterprops['function']], $args_array); - $genericotemplate = str_replace('@@renderedcontent@@',$renderedcontent, $genericotemplate); + try { + if (!isset($token)) { + $token = false; + } + $somerenderer = $PAGE->get_renderer($filterprops['renderer']); + $args = []; + if (isset($filterprops['args'])) { + $args_string = str_replace('cloudpoodlltoken', $token, $filterprops['args']); + $args_array = explode('|', $args_string); + } + $renderedcontent = call_user_func_array([$somerenderer, $filterprops['function']], $args_array); + $genericotemplate = str_replace('@@renderedcontent@@', $renderedcontent, $genericotemplate); + } catch (Exception $e) { + $genericotemplate = str_replace('@@renderedcontent@@', 'Failed to render!!', $genericotemplate); + } } //If template requires a MOODLEPAGEID lets give them one