mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 14:27:22 +01:00
MDL-24148 bit more reordering - delete blocks before activities because they might use module data
This commit is contained in:
parent
b2cd657023
commit
9aeaf4c622
@ -4127,6 +4127,9 @@ function remove_course_contents($courseid, $showfeedback = true) {
|
||||
'coursemoduleid IN (SELECT id from {course_modules} WHERE course=?)',
|
||||
array($courseid));
|
||||
|
||||
// Delete course blocks - they may depend on modules so delete them first
|
||||
blocks_delete_all_for_context($context->id);
|
||||
|
||||
// Delete every instance of every module
|
||||
if ($allmods = $DB->get_records('modules') ) {
|
||||
foreach ($allmods as $mod) {
|
||||
@ -4152,12 +4155,13 @@ function remove_course_contents($courseid, $showfeedback = true) {
|
||||
}
|
||||
if ($cm) {
|
||||
// delete cm and its context in correct order
|
||||
delete_context(CONTEXT_MODULE, $cm->id); // some callbacks may try to fetch context, better delete first
|
||||
$DB->delete_records('course_modules', array('id'=>$cm->id));
|
||||
delete_context(CONTEXT_MODULE, $cm->id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//note: we should probably delete these anyway
|
||||
echo $OUTPUT->notification('Function '.$moddelete.'() doesn\'t exist!');
|
||||
}
|
||||
|
||||
@ -4171,9 +4175,6 @@ function remove_course_contents($courseid, $showfeedback = true) {
|
||||
}
|
||||
}
|
||||
|
||||
// Delete course blocks
|
||||
blocks_delete_all_for_context($context->id);
|
||||
|
||||
// Delete any groups, removing members and grouping/course links first.
|
||||
groups_delete_groupings($course->id, $showfeedback);
|
||||
groups_delete_groups($course->id, $showfeedback);
|
||||
|
Loading…
x
Reference in New Issue
Block a user