Permalink
Browse files

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

… MOODLE_23_STABLE
  • Loading branch information...
2 parents f8ecf7f + c814b84 commit a6a1b51259e3ad19ec855625842762d3d2b94a8f @stronk7 stronk7 committed Feb 19, 2013
Showing with 8 additions and 1 deletion.
  1. +8 −1 question/format/xml/format.php
View
9 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 a6a1b51

Please sign in to comment.