Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#32158 closed defect (bug) (fixed)

wp_update_user() fails if email field case doesn't match

Reported by: davidjbullock's profile davidjbullock Owned by: wonderboymusic's profile wonderboymusic
Milestone: 4.2.3 Priority: normal
Severity: normal Version: 4.2
Component: Users Keywords: has-patch
Focuses: administration Cc:

Description

When calling wp_update_user() if the case of the current email address matches the old email address, with the exception of the case being different, than then entire wp_update_user() call fails with an error that the email address is already in use.

example:
test @ example.com vs. test @ Example.com

This can be easily tested in the user editor by opening a usser, changing the email case only, and trying to save it.

The behavior is inconsistent in handling email addresses as either case-sensitive or not. In theory the LHS of the email address could be case sensitive, but this not the case in practice.

In any case, the change should succeed, if the check is case sensitive, then the email addresses are different and there is no duplication. If the addresses are the same, then it should succeed because its updating the current record.

Attachments (4)

32158.diff (616 bytes) - added by pareshradadiya 10 years ago.
Case insensitive comparison of new email id with an user's old email id
32158.test.diff (845 bytes) - added by collinsinternet 10 years ago.
Unit test for patch.
32158.test.2.diff (1.5 KB) - added by collinsinternet 10 years ago.
Unit test to verify that patch doesn't affect change of email address.
32158.test.3.diff (1.3 KB) - added by tyxla 10 years ago.
Updating the unit tests by @collinsinternet to make them apply cleanly and fix a couple of minor things.

Download all attachments as: .zip

Change History (12)

#1 @davidjbullock
10 years ago

I believe this can easily be fixed by changing the comparison in wp_update_user() of the old and new email address to be normalized before comparison.

@pareshradadiya
10 years ago

Case insensitive comparison of new email id with an user's old email id

#2 @pareshradadiya
10 years ago

  • Keywords has-patch added

#3 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 4.2.2

Introduced in [31963].

@collinsinternet
10 years ago

Unit test for patch.

#4 @collinsinternet
10 years ago

  • Keywords needs-testing added

#5 @samuelsidler
10 years ago

  • Milestone changed from 4.2.2 to 4.2.3

@collinsinternet
10 years ago

Unit test to verify that patch doesn't affect change of email address.

#6 @MikeHansenMe
10 years ago

  • Keywords needs-testing removed

@tyxla
10 years ago

Updating the unit tests by @collinsinternet to make them apply cleanly and fix a couple of minor things.

#7 @tyxla
10 years ago

The 32158.test.2.diff patch was not applying cleanly for me, I noticed that there are several things that can be improved as well.

I've just submitted an updated version of the unit tests by @collinsinternet with the following improvements:

  1. Instead of testing for $this->assertFalse( is_wp_error( $update ) );, it is better to test vs. the user's ID, which is the result of wp_update_user() when update was successful.
  2. Removed the unnecessary information

#8 @wonderboymusic
10 years ago

  • Owner set to wonderboymusic
  • Resolution set to fixed
  • Status changed from new to closed

In 33115:

In wp_insert_user(), comparing an email address against the user's old email address should not be case-sensitive.

Adds unit tests.

Props tyxla.
Fixes #32158.

Note: See TracTickets for help on using tickets.