From 58404f0ab4bd5a2419ba4e8ef12492da2381c550 Mon Sep 17 00:00:00 2001 From: sam marshall Date: Tue, 9 Apr 2013 17:35:39 +0100 Subject: [PATCH] MDL-39000 Conditional activities: Section condition restore errors --- backup/moodle2/restore_stepslib.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index 74e8cae7766..df0c391b307 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -1274,7 +1274,7 @@ class restore_section_structure_step extends restore_structure_step { // Otherwise, when you restore to an existing course, it will mess up // existing section availability entries. if (!$this->get_mappingid('course_sections_availability', $data->id, false)) { - return; + continue; } // Update source cmid / grade id to new value. @@ -1287,7 +1287,12 @@ class restore_section_structure_step extends restore_structure_step { $data->gradeitemid = null; } - $DB->update_record('course_sections_availability', $data); + // Delete the record if the condition wasn't found, otherwise update it. + if ($data->sourcecmid === null && $data->gradeitemid === null) { + $DB->delete_records('course_sections_availability', array('id' => $data->id)); + } else { + $DB->update_record('course_sections_availability', $data); + } } } }