From 74475e5bb41b60deb2d46e03473e8f20e0033bfa Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 21 Sep 2017 11:09:50 +0800 Subject: [PATCH] MDL-59890 calendar: Delete category events upon category removal --- lib/coursecatlib.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/coursecatlib.php b/lib/coursecatlib.php index 916c7d830e9ac..02123a1b702d9 100644 --- a/lib/coursecatlib.php +++ b/lib/coursecatlib.php @@ -1756,6 +1756,9 @@ public function delete_full($showfeedback = true) { throw new moodle_exception('cannotdeletecategoryquestions', '', '', $this->get_formatted_name()); } + // Delete all events in the category. + $DB->delete_records('event', array('categoryid' => $this->id)); + // Finally delete the category and it's context. $DB->delete_records('course_categories', array('id' => $this->id));