MDL-44626 files: Show the PHP max upload size instead of 'unlimited'
authorAndrew Nicols <andrew@nicols.co.uk>
Fri, 14 Aug 2015 06:03:20 +0000 (14:03 +0800)
committerAndrew Nicols <andrew@nicols.co.uk>
Thu, 11 Feb 2016 02:55:54 +0000 (10:55 +0800)
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
webservice/tests/externallib_test.php

index 5e04581..24c9f9c 100644 (file)
@@ -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);
index 5c80986..9d98d35 100644 (file)
@@ -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']);