From 0cd43cccbf7342db8460bee2a76c47f29bd8fe55 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 28 Sep 2018 14:39:17 +0800 Subject: [PATCH] MDL-63401 core: Do not delete the user context As long as we have a user record, we should not delete the context which relates to it. --- lib/moodlelib.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 1fcb011c111..bb4c642a807 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -4146,8 +4146,8 @@ function delete_user(stdClass $user) { // Don't trigger update event, as user is being deleted. user_update_user($updateuser, false, false); - // Now do a final accesslib cleanup - removes all role assignments in user context and context itself. - context_helper::delete_instance(CONTEXT_USER, $user->id); + // Delete all content associated with the user context, but not the context itself. + $usercontext->delete_content(); // Any plugin that needs to cleanup should register this event. // Trigger event.