Skip to content

Commit

Permalink
fixes bug in data delete_data_for_users() implementation.
Browse files Browse the repository at this point in the history
ensure that only the records for the given user are deleted by checking
for its inclusion in the approved users list.
  • Loading branch information
stopfstedt committed Jun 6, 2024
1 parent ab35dab commit 7a69bd9
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,10 @@ public static function get_users_in_context(userlist $userlist): void {
* @throws dml_exception
*/
public static function delete_data_for_users(approved_userlist $userlist): void {
$users = $userlist->get_users();
foreach ($users as $user) {
$contextlist = new approved_contextlist(
$user,
'block_course_recent',
[context_user::instance($user->id)->id]
);
self::delete_data_for_user($contextlist);
global $DB;
$context = $userlist->get_context();
if ($context instanceof context_user && in_array($context->instanceid, $userlist->get_userids())) {
$DB->delete_records('block_course_recent', ['userid' => $context->instanceid]);
}
}
}

0 comments on commit 7a69bd9

Please sign in to comment.