Permalink
Browse files

MDL-29598 backup Check whether a grade_letters record exists before t…

…rying to insert a new record
  • Loading branch information...
1 parent d71c486 commit 5bc8335c6faa14e3fe04692b02391045d0f01ac7 @jfilip jfilip committed with dmonllao Dec 2, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 backup/moodle2/restore_stepslib.php
@@ -270,7 +270,15 @@ protected function process_grade_letter($data) {
$data->contextid = context_course::instance($this->get_courseid())->id;
- $newitemid = $DB->insert_record('grade_letters', $data);
+ // MDL-29598 - Don't insert a duplicate record if this grade letter already exists
+ $gltest = (array)$data;
+ unset($gltest['id']);
+ if (!$DB->record_exists('grade_letters', $gltest)) {
+ $newitemid = $DB->insert_record('grade_letters', $data);
+ } else {
+ $newitemid = $data->id;
+ }
+
$this->set_mapping('grade_letter', $oldid, $newitemid);
}
protected function process_grade_setting($data) {

0 comments on commit 5bc8335

Please sign in to comment.