Make WordPress Core

Ticket #28435: 28435.2.diff

File 28435.2.diff, 1.3 KB (added by tbcorr, 10 years ago)
  • src/wp-includes/user.php

     
    18871887 * @return int|WP_Error The updated user's ID or a WP_Error object if the user could not be updated.
    18881888 */
    18891889function wp_update_user($userdata) {
    1890         if ( is_a( $userdata, 'stdClass' ) )
     1890        if ( is_a( $userdata, 'stdClass' ) ) {
    18911891                $userdata = get_object_vars( $userdata );
    1892         elseif ( is_a( $userdata, 'WP_User' ) )
     1892        } elseif ( is_a( $userdata, 'WP_User' ) ) {
    18931893                $userdata = $userdata->to_array();
     1894        }
    18941895
    18951896        $ID = (int) $userdata['ID'];
    18961897
    18971898        // First, get all of the original fields
    18981899        $user_obj = get_userdata( $ID );
    1899         if ( ! $user_obj )
     1900        if ( ! $user_obj ) {
    19001901                return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
     1902        }
    19011903
    19021904        $user = $user_obj->to_array();
    19031905
     
    19101912        $user = add_magic_quotes( $user );
    19111913
    19121914        // If password is changing, hash it now.
    1913         if ( ! empty($userdata['user_pass']) ) {
     1915        if ( ! empty( $userdata['user_pass'] ) && $userdata['user_pass'] !== $user_obj->user_pass ) {
    19141916                $plaintext_pass = $userdata['user_pass'];
    19151917                $userdata['user_pass'] = wp_hash_password($userdata['user_pass']);
    19161918        }