Commit 7b030921 authored by David Monllaó's avatar David Monllaó
Browse files

Merge branch 'MDL-53501-master' of git://github.com/jleyva/moodle

parents 5dbd0515 c851ee5d
......@@ -188,11 +188,12 @@ class core_webservice_external extends external_api {
// User quota. 0 means user can ignore the quota.
$siteinfo['userquota'] = 0;
if (!has_capability('moodle/user:ignoreuserquota', $context)) {
$siteinfo['userquota'] = $CFG->userquota;
$siteinfo['userquota'] = (int) $CFG->userquota; // Cast to int to ensure value is not higher than PHP_INT_MAX.
}
// User max upload file size. -1 means the user can ignore the upload file size.
$siteinfo['usermaxuploadfilesize'] = get_user_max_upload_file_size($context, $CFG->maxbytes);
// Cast to int to ensure value is not higher than PHP_INT_MAX.
$siteinfo['usermaxuploadfilesize'] = (int) get_user_max_upload_file_size($context, $CFG->maxbytes);
// User home page.
$siteinfo['userhomepage'] = get_home_page();
......
......@@ -161,4 +161,21 @@ class core_webservice_externallib_testcase extends externallib_advanced_testcase
}
/**
* Test get_site_info with values > PHP_INT_MAX. We check only userquota since maxbytes require PHP ini changes.
*/
public function test_get_site_info_max_int() {
$this->resetAfterTest(true);
self::setUser(self::getDataGenerator()->create_user());
// Check values higher than PHP_INT_MAX. This value may come from settings (as string).
$userquota = PHP_INT_MAX . '000';
set_config('userquota', $userquota);
$result = core_webservice_external::get_site_info();
$result = external_api::clean_returnvalue(core_webservice_external::get_site_info_returns(), $result);
$this->assertEquals(PHP_INT_MAX, $result['userquota']);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment