From d90e49f238d3afd5591d1530d914ff2aae9f320e Mon Sep 17 00:00:00 2001 From: Eloy Lafuente Date: Wed, 15 Sep 2010 13:43:06 +0000 Subject: [PATCH] MDL-22179 backup - ensure we have the old/new courseid mapping available always --- backup/moodle2/restore_stepslib.php | 8 +++++--- backup/util/plan/restore_task.class.php | 4 ++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 162b8fcf9f9ef..ff4a9db76a826 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -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); + } } @@ -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(); diff --git a/backup/util/plan/restore_task.class.php b/backup/util/plan/restore_task.class.php index 11beb74302843..fa8a43bdacd1c 100644 --- a/backup/util/plan/restore_task.class.php +++ b/backup/util/plan/restore_task.class.php @@ -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; }