From 63b1eaf29c86476e9ad7b47e011f71ad8075b64d Mon Sep 17 00:00:00 2001 From: cescobedo Date: Tue, 5 Feb 2019 12:51:34 +0100 Subject: [PATCH] MDL-64714 core_auth: Fix early break foreach in delete_data_for_user --- auth/mnet/classes/privacy/provider.php | 10 ++++++---- auth/oauth2/classes/privacy/provider.php | 9 ++++++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/auth/mnet/classes/privacy/provider.php b/auth/mnet/classes/privacy/provider.php index f2f536dc124d9..416d01f622adb 100644 --- a/auth/mnet/classes/privacy/provider.php +++ b/auth/mnet/classes/privacy/provider.php @@ -273,13 +273,15 @@ public static function delete_data_for_user(approved_contextlist $contextlist) { return; } + $userid = $contextlist->get_user()->id; foreach ($contextlist->get_contexts() as $context) { if ($context->contextlevel != CONTEXT_USER) { - return; + continue; + } + if ($context->instanceid == $userid) { + // Because we only use user contexts the instance ID is the user ID. + $DB->delete_records('mnet_log', ['userid' => $context->instanceid]); } - - // Because we only use user contexts the instance ID is the user ID. - $DB->delete_records('mnet_log', ['userid' => $context->instanceid]); } } } diff --git a/auth/oauth2/classes/privacy/provider.php b/auth/oauth2/classes/privacy/provider.php index d0dfa65767251..3dcc08706f416 100644 --- a/auth/oauth2/classes/privacy/provider.php +++ b/auth/oauth2/classes/privacy/provider.php @@ -178,12 +178,15 @@ public static function delete_data_for_user(approved_contextlist $contextlist) { if (empty($contextlist->count())) { return; } + $userid = $contextlist->get_user()->id; foreach ($contextlist->get_contexts() as $context) { if ($context->contextlevel != CONTEXT_USER) { - return; + continue; + } + if ($context->instanceid == $userid) { + // Because we only use user contexts the instance ID is the user ID. + static::delete_user_data($context->instanceid); } - // Because we only use user contexts the instance ID is the user ID. - static::delete_user_data($context->instanceid); } }