For example, if I have a user (created before remove_username was installed) with username foo@example.com and e-mail bar@example.com and I try to create a new user with email foo@example.com, it will trigger this SQL error :

SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'foo@example.com-fr' for key 'user__name': INSERT INTO {users_field_data}   

The attached patch avoids this by checking if the username already exists.
It also checks the email with user_validate_name() because the username field has more strict rules than the email field.

Comments

prudloff created an issue. See original summary.

prudloff’s picture

StatusFileSize
new1.04 KB

Updated patch to:

  • Not return an error when the existing user is the one we are editing.
  • Display the error on the correct field.

  • sadashiv committed a2b0aff on 8.x-1.x authored by prudloff
    Issue #3136187 by prudloff: SQL error when username is already taken
    
sadashiv’s picture

Status: Needs review » Fixed

Thanks for this patch, Have pushed this.

Thanks,
Sadashiv

Status: Fixed » Closed (fixed)

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