Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-37967_23' of git://github.com/jmvedrine/moodle into…

… MOODLE_23_STABLE
  • Loading branch information...
commit a6a1b51259e3ad19ec855625842762d3d2b94a8f 2 parents f8ecf7f + c814b84
Eloy Lafuente (stronk7) stronk7 authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 question/format/xml/format.php
9 question/format/xml/format.php
View
@@ -170,16 +170,23 @@ public function import_files_as_draft($xml) {
}
$fs = get_file_storage();
$itemid = file_get_unused_draft_itemid();
+ $filenames = array();
foreach ($xml as $file) {
+ $filename = $file['@']['name'];
+ if (in_array($filename, $filenames)) {
+ debugging('Duplicate file in XML: ' . $filename, DEBUG_DEVELOPER);
+ continue;
+ }
$filerecord = array(
'contextid' => context_user::instance($USER->id)->id,
'component' => 'user',
'filearea' => 'draft',
'itemid' => $itemid,
'filepath' => '/',
- 'filename' => $file['@']['name'],
+ 'filename' => $filename,
);
$fs->create_file_from_string($filerecord, base64_decode($file['#']));
+ $filenames[] = $filename;
}
return $itemid;
}
Please sign in to comment.
Something went wrong with that request. Please try again.