From 6ebff58d8c5a86cb7dbd08b47e10f8010063473b Mon Sep 17 00:00:00 2001 From: John Okely Date: Tue, 23 May 2017 09:17:29 +0800 Subject: [PATCH] MDL-57103 lib: Force ajax renderer for all ajax fatal errors --- lib/setuplib.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/setuplib.php b/lib/setuplib.php index 9759ced0279..6fa970cc569 100644 --- a/lib/setuplib.php +++ b/lib/setuplib.php @@ -384,7 +384,14 @@ function default_exception_handler($ex) { // If you enable db debugging and exception is thrown, the print footer prints a lot of rubbish $DB->set_debug(0); } - echo $OUTPUT->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, + if (AJAX_SCRIPT) { + // If we are in an AJAX script we don't want to use PREFERRED_RENDERER_TARGET. + // Because we know we will want to use ajax format. + $renderer = $PAGE->get_renderer('core', null, 'ajax'); + } else { + $renderer = $OUTPUT; + } + echo $renderer->fatal_error($info->message, $info->moreinfourl, $info->link, $info->backtrace, $info->debuginfo, $info->errorcode); } catch (Exception $e) { $out_ex = $e;