From cbce7be769fb36ed597e6e9c75c6445c15f9bb22 Mon Sep 17 00:00:00 2001 From: Dan Poltawski Date: Tue, 16 Feb 2016 10:01:45 +0000 Subject: [PATCH] MDL-28030 setup: Ensure $CFG->urlrewriteclass is properly setup (To avoid crippling a site) --- lib/setup.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/setup.php b/lib/setup.php index a1324f00529..4c5930bc03f 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -947,6 +947,17 @@ if ($USER && function_exists('apache_note') apache_note('MOODLEUSER', $logname); } +// Ensure the urlrewriteclass is setup correctly (to avoid crippling site). +if (isset($CFG->urlrewriteclass)) { + if (!class_exists($CFG->urlrewriteclass)) { + debugging("urlrewriteclass {$CFG->urlrewriteclass} was not found, disabling."); + unset($CFG->urlrewriteclass); + } else if (!in_array('core\output\url_rewriter', class_implements($CFG->urlrewriteclass))) { + debugging("{$CFG->urlrewriteclass} does not implement core\output\url_rewriter, disabling.", DEBUG_DEVELOPER); + unset($CFG->urlrewriteclass); + } +} + // Use a custom script replacement if one exists if (!empty($CFG->customscripts)) { if (($customscript = custom_script_path()) !== false) {