Bulk delete: Empty username fails with error/moodle/usernamelowercase

Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Visvanath Ratnaweera -
Number of replies: 8
Picture of Particularly helpful Moodlers Picture of Translators
I have a site where the "No authentication" plug-in is activated. (I know, the security report categorize this setting as 'critical'. But that is what the site administrator wants.) The problem with this setting is that, failed login attempts of users create new users! The site administrator was used to clean them through bulk user action. Say select all with empty Firstname, Lastname and E-Mail and delete the selection.

During the last attempt it brings:
Only lowercase allowed (my translation)
Debug info:
Error code: usernamelowercase
Stack trace:
line 120 of /user/lib.php: moodle_exception thrown
line 4289 of /lib/moodlelib.php: call to user_update_user()
line 30 of /admin/user/user_bulk_delete.php: call to delete_user()

Link to further info:
https://docs.moodle.org/27/de/error/moodle/usernamelowercase

Is this is a result of an added security mechanism? What is the best way out?

[Moodle 2.7.1+ (Build: 20140731)] (I know, 2.7 is no more supported except for security exploits. But don't just tell me to upgrade, unless you know that the target version, ideally 2.7.latest, does not have this "bug".)
Average of ratings: -
In reply to Visvanath Ratnaweera

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I can't understand how you end up at the user_update_user() function with an empty username in the first place. You can't have a user profile with a blank username surely? There's a bigger bug here if so.

Can you step through how to reproduce this (assuming that we don't have 'no authentication' enabled in the first place)?

In reply to Howard Miller

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Thanks!

No, I don't think you can maneuver in to this corner without the help of "No authentication".
sad

OK, now step-by-step.
- Site administration > Plugins > Authentication > No authentication is active with First name, Surname and Email address, amoung other things, are unlocked.

- Site administration > Plugins > Authentication > Manage authentication shows 7 Manual accounts, 0 No logins and 4517(!) No authentication accounts.

- Once I go to Site administration > Users > Accounts > Bulk user actions and filter User full name, Surname, First name, Email address all "is empty" the column Available shows "All filtered (1306/4523)".

- Now I say, Add to selection, Selection responds with "All selected (1306/4523)"

- Then With selected users... > Delete > Go I get a " Are you absolutely sure you want to completely delete" followed by a whole page of dots.

- The Yes to that brings the error already mentioned:
Only lowercase letters allowed
Debug info:
Error code: usernamelowercase
Stack trace:
line 120 of /user/lib.php: moodle_exception thrown
line 4289 of /lib/moodlelib.php: call to user_update_user()
line 30 of /admin/user/user_bulk_delete.php: call to delete_user()

I may find a SQL to purge those users. But that would be as a last resort. I want the site admin to be able to repeat the exercise (and take the responsibility ;).
In reply to Visvanath Ratnaweera

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Unsure... I'll need to attempt to reproduce this to find out what has gone wrong. It sounds like one of those things that nobody is likely to have tested. 

I'll have a try but it might not be today wink

In reply to Howard Miller

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
Howard

I didn't mean that! Unless "No authentication" is your child, don't spend your time on this. Just shift the discussion to the Authentication forum. I need to have a second look anyway.
In reply to Visvanath Ratnaweera

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I doubt it's anybody's child. Moving to authentication, but if I get a minute I'll have a try. I like a mystery smile

In reply to Visvanath Ratnaweera

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase

by Shawn Peters -

Just came across this exact same error when we tried to delete some old accounts.  Were on Moodle 2.8

All our accounts are setup via LDAP sync, but there were and handful of accounts that didn't have an e-mail address setup.


I did an export of the accounts that i needed to delete, added in a bogus email address to them all. Imported users to update the existing accounts and then re-ran the Bulk delete.

Worked like a charm.  smile


Thanks for the help in finding out the issue on this one.

-Shawn

Average of ratings: Useful (1)
In reply to Visvanath Ratnaweera

Re: Bulk delete: Empty username fails with error/moodle/usernamelowercase [RESOLVED]

by Visvanath Ratnaweera -
Picture of Particularly helpful Moodlers Picture of Translators
The problem vanished after upgrading to 2.9.3 (from Moodle 2.7.1).

@Howard, thanks a lot for your support and sorry for the very late report!