Permalink
Browse files

MDL-14326 Remove all course_modules that remained empty (i.e. with in…

…stance==0) after the particular restore process. Backported from MOODLE_19_STABLE
  • Loading branch information...
1 parent dc5f29b commit 4ec9d6b07d8ab7840509f637f31cf8476b848a04 mudrd8mz committed Aug 21, 2008
Showing with 12 additions and 0 deletions.
  1. +12 −0 backup/restorelib.php
View
@@ -3343,6 +3343,18 @@ function restore_check_instances($restore) {
} else {
$status = false;
}
+ // MDL-14326 remove empty course modules instance's (credit goes to John T. Macklin from Remote Learner)
+ $course_modules_inst_zero = get_records_sql("SELECT id, course, instance
+ FROM {$CFG->prefix}course_modules
+ WHERE id = '$cm_module->new_id' AND
+ instance = '0'");
+
+ if($course_modules_inst_zero){ // Clean up the invalid instances
+ foreach($course_modules_inst_zero as $course_modules_inst){
+ delete_records('course_modules', 'id',$course_modules_inst->id);
+ }
+ }
+
}
}

0 comments on commit 4ec9d6b

Please sign in to comment.