MDL-64714 core_auth: Fix early break foreach in delete_data_for_user
authorcescobedo <carlos.escobedo@gmail.com>
Tue, 5 Feb 2019 11:51:34 +0000 (12:51 +0100)
committercescobedo <carlos.escobedo@gmail.com>
Tue, 5 Feb 2019 11:51:34 +0000 (12:51 +0100)
auth/mnet/classes/privacy/provider.php
auth/oauth2/classes/privacy/provider.php

index f2f536d..416d01f 100644 (file)
@@ -273,13 +273,15 @@ class provider implements
             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]);
         }
     }
 }
index d0dfa65..3dcc087 100644 (file)
@@ -178,12 +178,15 @@ class provider implements
         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);
         }
     }