MDL-52100 filelib: Files that are oversized are checked with user.

Files that are oversized could have been uploaded by a user who
can ignore the file size limits. These files should not be deleted
in these situations.
This commit is contained in:
Adrian Greeve
2017-12-18 13:18:11 +08:00
parent fb20acf02d
commit 74798df3e9
+6 -2
View File
@@ -848,6 +848,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;
@@ -856,8 +857,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) {