Skip to content

Commit

Permalink
MDL-22179 backup - ensure we have the old/new courseid mapping availa…
Browse files Browse the repository at this point in the history
…ble always
  • Loading branch information
stronk7 committed Sep 15, 2010
1 parent cfea745 commit d90e49f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ protected function define_execution() {
$itemid = $this->task->get_old_system_contextid();
$newitemid = get_context_instance(CONTEXT_SYSTEM)->id;
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'context', $itemid, $newitemid);
// Create the old-course-id to new-course-id mapping, we need that available since the beginning
$itemid = $this->task->get_old_courseid();
$newitemid = $this->get_courseid();
restore_dbops::set_backup_ids_record($this->get_restoreid(), 'course', $itemid, $newitemid);

}
}

Expand Down Expand Up @@ -950,9 +955,6 @@ public function process_course($data) {
// Course record ready, update it
$DB->update_record('course', $data);

// Set course mapping
$this->set_mapping('course', $oldid, $data->id);

// Course tags
if (!empty($CFG->usetags) && isset($coursetags)) { // if enabled in server and present in backup
$tags = array();
Expand Down
4 changes: 4 additions & 0 deletions backup/util/plan/restore_task.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ public function get_tempdir() {
return $this->plan->get_tempdir();
}

public function get_old_courseid() {
return $this->plan->get_info()->original_course_id;
}

public function get_old_contextid() {
return $this->plan->get_info()->original_course_contextid;
}
Expand Down

0 comments on commit d90e49f

Please sign in to comment.