MDL-52831 users: Do not delete Mr. and Mrs. Whitespace accounts

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.
This commit is contained in:
David Mudrák
2016-01-19 21:40:45 +01:00
parent e9c27d1e0e
commit 1ccd813264
@@ -59,6 +59,10 @@ class delete_incomplete_users_task extends scheduled_task {
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)");
}