Skip to content
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 bac15e5 commit 44ec173ea8fea922f191508d317ab6f5d682f952 @jfilip jfilip committed with dmonllao Dec 2, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 backup/moodle2/restore_stepslib.php
View
10 backup/moodle2/restore_stepslib.php
@@ -270,7 +270,15 @@ protected function process_grade_letter($data) {
$data->contextid = get_context_instance(CONTEXT_COURSE, $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 44ec173

Please sign in to comment.
Something went wrong with that request. Please try again.