MDL-37078: Restore - section restore fails with multiple availability conditions
authorsam marshall <s.marshall@open.ac.uk>
Wed, 12 Dec 2012 10:47:17 +0000 (10:47 +0000)
committersam marshall <s.marshall@open.ac.uk>
Wed, 12 Dec 2012 12:19:59 +0000 (12:19 +0000)
backup/moodle2/restore_stepslib.php
lib/conditionlib.php

index 103fb3d..59477cc 100644 (file)
@@ -1151,11 +1151,11 @@ class restore_section_structure_step extends restore_structure_step {
         $sectionid = $this->get_task()->get_sectionid();
 
         // Get data object for current section availability (if any).
-        $data = $DB->get_record('course_sections_availability',
-                array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid', IGNORE_MISSING);
+        $records = $DB->get_records('course_sections_availability',
+                array('coursesectionid' => $sectionid), 'id, sourcecmid, gradeitemid');
 
         // If it exists, update mappings.
-        if ($data) {
+        foreach ($records as $data) {
             // Only update mappings for entries which are created by this restore.
             // Otherwise, when you restore to an existing course, it will mess up
             // existing section availability entries.
index 550d49a..c1a0851 100644 (file)
@@ -760,7 +760,7 @@ abstract class condition_info_base {
                 if (empty($modinfo->cms[$cmid])) {
                     global $PAGE, $UNITTEST;
                     if (!empty($UNITTEST) || (isset($PAGE) && strpos($PAGE->pagetype, 'course-view-')===0)) {
-                        debugging("Warning: activity {$this->cm->id} '{$this->cm->name}' has condition " .
+                        debugging("Warning: activity {$this->item->id} '{$this->item->name}' has condition " .
                                 "on deleted activity $cmid (to get rid of this message, edit the named activity)");
                     }
                     continue;