Permalink
Browse files

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

… MOODLE_24_STABLE
  • Loading branch information...
2 parents 950fead + ddc03b1 commit 097404cd2bb38cfb8497e319dc210625479b330e @stronk7 stronk7 committed Feb 19, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 question/format/xml/format.php
@@ -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;
}

0 comments on commit 097404c

Please sign in to comment.