Skip to content

Commit

Permalink
MDL-52831 users: Do not delete Mr. and Mrs. Whitespace accounts
Browse files Browse the repository at this point in the history
Due to imperfect validation of the user registration and profile forms,
we allowed for firstname and lastname be just a whitespace. On MySQL,
such a whitespace is not significant for VARCHAR comparison so these
otherwise valid accounts could be silently deleted.

The patch makes sure that at least one of the checked fields is a real
empty string before deleting such account.
  • Loading branch information
mudrd8mz committed Jan 19, 2016
1 parent e9c27d1 commit 1ccd813
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/classes/task/delete_incomplete_users_task.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ public function execute() {
if (isguestuser($user) or is_siteadmin($user)) {
continue;
}
if ($user->lastname !== '' and $user->firstname !== '' and $user->email !== '') {
// This can happen on MySQL - see MDL-52831.
continue;
}
delete_user($user);
mtrace(" Deleted not fully setup user $user->username ($user->id)");
}
Expand Down

0 comments on commit 1ccd813

Please sign in to comment.