From 946281d2827c799b44d99ee3c0ed3e1220615c08 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Tue, 15 Nov 2016 12:36:37 +0800 Subject: [PATCH] MDL-56958 ajax: Prefer the general renderer --- lib/ajax/service.php | 2 ++ lib/outputfactories.php | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/ajax/service.php b/lib/ajax/service.php index 4a0a1db7030..3298c0e7a75 100644 --- a/lib/ajax/service.php +++ b/lib/ajax/service.php @@ -32,6 +32,8 @@ define('AJAX_SCRIPT', true); require_once(__DIR__ . '/../../config.php'); require_once($CFG->libdir . '/externallib.php'); +define('PREFERRED_RENDERER_TARGET', RENDERER_TARGET_GENERAL); + $rawjson = file_get_contents('php://input'); $requests = json_decode($rawjson, true); diff --git a/lib/outputfactories.php b/lib/outputfactories.php index 2d7cabfec45..aa28a9e6901 100644 --- a/lib/outputfactories.php +++ b/lib/outputfactories.php @@ -137,7 +137,9 @@ abstract class renderer_factory_base implements renderer_factory { // If the target hasn't been specified we need to guess the defaults. // We also override the target with the default if the maintenance target has been provided. // This ensures we don't use the maintenance renderer if we are processing a special target. - if (CLI_SCRIPT) { + if (defined('PREFERRED_RENDERER_TARGET')) { + $target = PREFERRED_RENDERER_TARGET; + } else if (CLI_SCRIPT) { $target = RENDERER_TARGET_CLI; } else if (AJAX_SCRIPT) { $target = RENDERER_TARGET_AJAX;