From 6a3aaf1803ca4c7cbd4b41edee00e59431845d2f Mon Sep 17 00:00:00 2001 From: Jake Dallimore Date: Tue, 19 Jun 2018 14:23:31 +0800 Subject: [PATCH] MDL-54830 core_course: fix maxbytes logic in course_update web service The service should allow the special value of 0 (site limit) to be set. --- course/externallib.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/course/externallib.php b/course/externallib.php index 251d761d1be..1777de1198b 100644 --- a/course/externallib.php +++ b/course/externallib.php @@ -933,7 +933,11 @@ class core_course_external extends external_api { // Make sure maxbytes are less then CFG->maxbytes. if (array_key_exists('maxbytes', $course)) { - $course['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $course['maxbytes']); + // We allow updates back to 0 max bytes, a special value denoting the course uses the site limit. + // Otherwise, either use the size specified, or cap at the max size for the course. + if ($course['maxbytes'] != 0) { + $course['maxbytes'] = get_max_upload_file_size($CFG->maxbytes, $course['maxbytes']); + } } if (!empty($course['courseformatoptions'])) {