From 9a968aa29e98d6232fba2e2923700e0699d2a979 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Fri, 8 Nov 2024 15:41:39 +0000 Subject: [PATCH] MDL-83674 Files: pluginfile.php debugging if user not allowed course --- pluginfile.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pluginfile.php b/pluginfile.php index 24e6cda10e9..fa53f8c4a3a 100644 --- a/pluginfile.php +++ b/pluginfile.php @@ -41,4 +41,10 @@ $preview = optional_param('preview', null, PARAM_ALPHANUM); // The repository may have to export the file to an offline format. $offline = optional_param('offline', 0, PARAM_BOOL); $embed = optional_param('embed', 0, PARAM_BOOL); + +// We need to set the page URL here because there are cases where file_pluginfile may display an +// error directly on the page instead of throwing an exception, and this will generate a server +// error if $PAGE->url is not defined. +$PAGE->set_url(new \moodle_url($FULLME)); + file_pluginfile($relativepath, $forcedownload, $preview, $offline, $embed);