From 6f0768618a38c11eca90a97c0dff31ec8ce434d1 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 14 Aug 2015 14:03:20 +0800 Subject: [PATCH] MDL-44626 files: Show the PHP max upload size instead of 'unlimited' Even when a user has the appropriate capability to upload any sized files, they are still restricted to the PHP post_max_size, and upload_max_filesize values. Rather than showing a value of "Unlimited', we should always restrict to this value. --- lib/moodlelib.php | 2 +- webservice/tests/externallib_test.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 5e045816adf..24c9f9c8693 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -6165,7 +6165,7 @@ function get_user_max_upload_file_size($context, $sitebytes = 0, $coursebytes = } if (has_capability('moodle/course:ignorefilesizelimits', $context, $user)) { - return USER_CAN_IGNORE_FILE_SIZE_LIMITS; + return get_max_upload_file_size(USER_CAN_IGNORE_FILE_SIZE_LIMITS); } return get_max_upload_file_size($sitebytes, $coursebytes, $modulebytes); diff --git a/webservice/tests/externallib_test.php b/webservice/tests/externallib_test.php index 5c809860edb..9d98d35a77e 100644 --- a/webservice/tests/externallib_test.php +++ b/webservice/tests/externallib_test.php @@ -151,7 +151,9 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase $siteinfo = external_api::clean_returnvalue(core_webservice_external::get_site_info_returns(), $siteinfo); $this->assertEquals(0, $siteinfo['userquota']); - $this->assertEquals(USER_CAN_IGNORE_FILE_SIZE_LIMITS, $siteinfo['usermaxuploadfilesize']); + + // The max_size is dependant upon the post_max_size, and upload_max_filesize values in php.ini. + $this->assertEquals(get_max_upload_file_size(USER_CAN_IGNORE_FILE_SIZE_LIMITS), $siteinfo['usermaxuploadfilesize']); $this->assertEquals(true, $siteinfo['usercanmanageownfiles']); $this->assertEquals(HOMEPAGE_SITE, $siteinfo['userhomepage']); -- 2.43.0