[wp-trac] [WordPress Trac] #30647: wp_update_user() allows using existing user_email, user_login, and user_nicename

WordPress Trac noreply at wordpress.org
Fri Dec 12 09:43:47 UTC 2014


#30647: wp_update_user() allows using existing user_email, user_login, and
user_nicename
------------------------------------------------+--------------------------
 Reporter:  danielbachhuber                     |       Owner:
     Type:  defect (bug)                        |      Status:  new
 Priority:  normal                              |   Milestone:  Future
Component:  Users                               |  Release
 Severity:  normal                              |     Version:
 Keywords:  dev-feedback has-patch 2nd-opinion  |  Resolution:
                                                |     Focuses:
------------------------------------------------+--------------------------

Comment (by rittesh.patel):

 Find the updated patch and test case for that patch in attachment.

 The old version of patch was throwing error for `test_update_user` check
 when checked with phpunit, it wasn't updating any detail of user at all
 when `! $update` removed from if condition.

 Following is the current code to check for email exist and throw WP_Error
 accordingly


 {{{
 ( ! $update && ! defined( 'WP_IMPORTING' ) && email_exists( $user_email )
 )
 }}}


 I have updated it to the following


 {{{
 ( ( ! $update || ( ! empty( $old_user_data ) && $user_email !==
 $old_user_data->user_email ) ) && ! defined( 'WP_IMPORTING' ) &&
 email_exists( $user_email ) )

 }}}

 It will simply first check whether these is update or insert, if it's
 insert just check for the email exist and if it's update than first check
 whether email has been changed or not and then check accordingly for email
 exist.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/30647#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list