From b26efcd8619ee4a78908d7d41c1d18b9d7f4e52b Mon Sep 17 00:00:00 2001 From: Neill Magill Date: Thu, 28 Feb 2019 10:09:04 +0000 Subject: [PATCH] MDL-64427 course: Mark activities during course contents deletion When we want to delete all of the activities in a course we should mark them as having a deletion in progress, as this makes them unavailable to users immediately. This should make it much less likely that a request to get a context that does not exist should be made when a user accesses a page. --- lib/moodlelib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index eb5147810f2..cb91da2f556 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -5245,6 +5245,9 @@ function remove_course_contents($courseid, $showfeedback = true, array $options echo $OUTPUT->notification($strdeleted.get_string('type_block_plural', 'plugin'), 'notifysuccess'); } + $DB->set_field('course_modules', 'deletioninprogress', '1', ['course' => $courseid]); + rebuild_course_cache($courseid, true); + // Get the list of all modules that are properly installed. $allmodules = $DB->get_records_menu('modules', array(), '', 'name, id');