[wp-trac] [WordPress Trac] #40497: wp_insert_user requires user_login when ID is given

WordPress Trac noreply at wordpress.org
Thu Apr 20 14:07:22 UTC 2017


#40497: wp_insert_user requires user_login when ID is given
----------------------------------+-----------------------------
 Reporter:  johnprestonsoapmedia  |      Owner:
     Type:  defect (bug)          |     Status:  new
 Priority:  normal                |  Milestone:  Awaiting Review
Component:  Users                 |    Version:  trunk
 Severity:  normal                |   Keywords:
  Focuses:                        |
----------------------------------+-----------------------------
 When passing an array containing an `ID` key to `wp_insert_user`, the
 local variable `$update` is set to `true` so that various checks
 throughout the function can be disabled.

 [https://core.trac.wordpress.org/browser/trunk/src/wp-
 includes/user.php#L1445 Line 1445]:

 {{{
  if ( empty( $user_login ) )
 }}}

 checks for the existence of the `user_login` key but does not include the
 check for `!$update`. This means that if an array of user meta to be
 updated is passed in with an `ID`, the array must also contain a
 `user_login`, otherwise a `WP_Error('empty_user_login')` will be thrown.

 In the case that `ID` is passed in but not `user_login`, this exception
 should not be thrown as `user_login` is redundant: `user_login` can be
 determined from the ID, and logic earlier in the function (see lines 1411
 onwards) determines that the user already exists and is to be updated.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/40497>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list