Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Merge branch 'wip-MDL-52100-master' of git://github.com/abgreeve/moodle
- Loading branch information
Showing
with
9 additions
and
4 deletions.
-
+6
−2
lib/filelib.php
-
+3
−2
lib/tests/filelib_test.php
|
@@ -904,6 +904,7 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea |
|
|
|
|
|
$newhashes = array(); |
|
|
$filecount = 0; |
|
|
$context = context::instance_by_id($contextid, MUST_EXIST); |
|
|
foreach ($draftfiles as $file) { |
|
|
if (!$options['subdirs'] && $file->get_filepath() !== '/') { |
|
|
continue; |
|
@@ -912,8 +913,11 @@ function file_save_draft_area_files($draftitemid, $contextid, $component, $filea |
|
|
continue; |
|
|
} |
|
|
if (!$file->is_directory()) { |
|
|
if ($options['maxbytes'] and $options['maxbytes'] < $file->get_filesize()) { |
|
|
// oversized file - should not get here at all |
|
|
// Check to see if this file was uploaded by someone who can ignore the file size limits. |
|
|
$fileusermaxbytes = get_user_max_upload_file_size($context, $options['maxbytes'], 0, 0, $file->get_userid()); |
|
|
if ($fileusermaxbytes != USER_CAN_IGNORE_FILE_SIZE_LIMITS |
|
|
&& ($options['maxbytes'] and $options['maxbytes'] < $file->get_filesize())) { |
|
|
// Oversized file. |
|
|
continue; |
|
|
} |
|
|
if ($options['maxfiles'] != -1 and $options['maxfiles'] <= $filecount) { |
|
|
|
@@ -1046,7 +1046,6 @@ public function test_file_rewrite_pluginfile_urls() { |
|
|
public static function create_draft_file($filedata = array()) { |
|
|
global $USER; |
|
|
|
|
|
self::setAdminUser(); |
|
|
$fs = get_file_storage(); |
|
|
|
|
|
$filerecord = array( |
|
@@ -1208,7 +1207,9 @@ public function test_file_merge_files_from_draft_area_into_filearea_max_file_byt |
|
|
global $USER; |
|
|
|
|
|
$this->resetAfterTest(true); |
|
|
$this->setAdminUser(); |
|
|
// The admin has no restriction for max file uploads, so use a normal user. |
|
|
$user = $this->getDataGenerator()->create_user(); |
|
|
$this->setUser($user); |
|
|
$fs = get_file_storage(); |
|
|
|
|
|
$file = self::create_draft_file(); |
|
|