Missing a user_load().

CommentFileSizeAuthor
#7 1033360_and_better_docs.patch3.33 KBgreggles
#4 bakery.diff2.85 KBdrumm
#1 bakery.diff789 bytesdrumm

Comments

drumm’s picture

Status: Active » Needs review
StatusFileSize
new789 bytes

Patch attached.

drumm’s picture

Priority: Normal » Critical

I believe this is helping cause uid 0 deletions. To reproduce, on a slave site, request a new password by email, where the slave site already has the account. Since bakery does not find an existing account, it goes through most of bakery_request_account(). At the end, it has a duplicate name and the last user_save() fails. The final cleanup does user_delete() on the empty account, deleting uid 0. The code should be more forgiving, but this patch is a start.

drumm’s picture

http://drupal.org/user/689172 and http://drupal.org/user/21209 existing doesn't help, but that's another issue.

drumm’s picture

Title: bakery_request_account() needs to check for existing email » bakery_request_account() needs to check for existing email and be better at cleanup
StatusFileSize
new2.85 KB

Added:
- Store the $stub_uid; $account->uid is lost during an unsuccessful user_save().
- Clean up the stray stub accounts that have not been used.

greggles’s picture

Great detective work, drumm. Were you able to deploy this anywhere to help test?

drumm’s picture

I tested a bit locally. The underlying condition on d.o, #1034852: Clean up accounts with case-insensitive duplicate names, is now fixed. The best test might involve hacking user_save() or the master server to sometimes fail.

greggles’s picture

Version: 6.x-2.x-dev » 7.x-1.x-dev
Status: Needs review » Patch (to be ported)
StatusFileSize
new3.33 KB

This line confused me at first:

+    $existing_account = user_load(array('mail' => $name));

I had forgotten why the $name might be used as an e-mail, but it's because this is sometimes coming from the password request form which allows either name or mail, so I added a little more to the doxygen to explain that it might be an e-mail even if the variable is called "$name".

Now committed to 6.x-2.x-dev http://drupal.org/cvs?commit=490722

coltrane’s picture

Status: Patch (to be ported) » Fixed

This made it in.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.