email_registration_unique_username says that $uid is optional, but it actually requires it.

Let's make it truly optional so this can be used before creating the user (i.e. before there is a uid).

Comments

greggles’s picture

Status: Active » Needs review
StatusFileSize
new1.05 KB

Status: Needs review » Needs work

The last submitted patch, 1: 2257201_optional_uid.patch, failed testing.

smichel’s picture

FWIW, the patch in #1 worked for me. Thanks @greggles!

greggles’s picture

@smichel hopefully you can just use latest 7.x-1.2 release which has this patch in it.

smichel’s picture

Thanks, @greggles, that version is working for me now.

thegreatone’s picture

I have the 7.x-1.2 release and don't see the code in there.
Also...in order to make it work like the module says it does:
"For example, "johndoe@a.example.com" would be assigned username "johndoe", "johndoe@b.example.com" would be assigned "johndoe_1" and so forth"

the line
if (!empty($uid)) {
// Put uid on the end of the name.
$name = $name . '_' . $uid;
}
in function email_registration_cleanup_username
need to be removed. Else if add the uid to every user even if the username don't exist already.

Correct?

awardell’s picture

StatusFileSize
new624 bytes

The 2257201_optional_uid.patch did not work for me. The fix was rather simple in fixTrailingUID-2257201.patch. It seems that the function email_registration_user_insert does everything needed to UID. Maybe I'm missing something?

greggles’s picture

The behavior removed by the patch in comment #7 was intentionally added in #423920: [2.x] Prevent race condition in account generation code by adding uid to name so I don't think removing it is the right solution.

evilehk’s picture

StatusFileSize
new603 bytes

I was experiencing the race condition issue from #423920: [2.x] Prevent race condition in account generation code by adding uid to name, so thank you for that commit! As a result of it, I found that my project had custom code looking if email_registration was enabled and using the email_registrartion_unique_username method, treating the $uid argument as optional.

At the very least, the (optional) comment should be removed from the phpdoc comment of that method. That is what this patch does. I will also follow up with an additional patch with the suggestion for modules to prepend 'email_registration_' to an account name about to be saved to initiate the hooks in the email_registration module, thus avoiding the race condition.

evilehk’s picture

Status: Needs work » Needs review
StatusFileSize
new1.07 KB
new822 bytes

This patch adds additional comments to the email_registration_unique_username method that custom module can take advantage of the email_registration user hooks by saving a user with a user name prepended with 'email_registration_'.

dxx’s picture

Ok for me.

  • greggles committed 5721c6f on 7.x-1.x authored by evilehk
    Issue #2257201 by evilehk, greggles, awardell: Make uid truly optional...
greggles’s picture

Status: Needs review » Fixed

Committed and pushed. Thanks!

Status: Fixed » Closed (fixed)

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

Status: Closed (fixed) » Needs work

The last submitted patch, 10: make_uid_truly_optional-2257201-10.patch, failed testing.

njbarrett’s picture

This patch was not properly committed to 7.x-1.x-dev.

evilehk's patch only contained comment changes not the original patch changes.

njbarrett’s picture

Status: Needs work » Needs review
StatusFileSize
new1.48 KB

This patch fixes the problem the original issue was created for: make the uid parameter optional in email_registration_unique_username

  • greggles committed 99cb6a8 on 7.x-1.x
    Issue #2257201 by njbarrett: Followup - make uid truly optional in...
greggles’s picture

Status: Needs review » Fixed

Good point, thanks njbarrett! Now committed.

Status: Fixed » Closed (fixed)

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