MDL-22179 backup - ensure we have the old/new courseid mapping available always
authorEloy Lafuente <stronk7@moodle.org>
Wed, 15 Sep 2010 13:43:06 +0000 (13:43 +0000)
committerEloy Lafuente <stronk7@moodle.org>
Wed, 15 Sep 2010 13:43:06 +0000 (13:43 +0000)
backup/moodle2/restore_stepslib.php
backup/util/plan/restore_task.class.php

index 162b8fc..ff4a9db 100644 (file)
@@ -47,6 +47,11 @@ class restore_create_and_clean_temp_stuff extends restore_execution_step {
         $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 @@ class restore_course_structure_step extends restore_structure_step {
         // 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();
index 11beb74..fa8a43b 100644 (file)
@@ -83,6 +83,10 @@ abstract class restore_task extends base_task {
         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;
     }