Permalink
Browse files

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

…stance==0) after the particular restore process.
  • Loading branch information...
mudrd8mz
mudrd8mz committed Aug 21, 2008
1 parent cd74712 commit 0738e88d48028cd5d0b9e4534fe03b65e7438142
Showing with 12 additions and 0 deletions.
  1. +12 −0 backup/restorelib.php
View
@@ -4405,6 +4405,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);
}
}
}
/// Finally, calculate modinfo cache.
rebuild_course_cache($restore->course_id);

0 comments on commit 0738e88

Please sign in to comment.