Make WordPress Core

Changeset 51399


Ignore:
Timestamp:
07/10/2021 12:20:55 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Coding Standards: Rename the $ID variable to $user_id in wp_insert_user() and wp_update_user().

This fixes a "Variable $ID is not in valid snake_case format" WPCS warning.

Follow-up to [2872].

See #53359.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r51398 r51399  
    17741774        // Are we updating or creating?
    17751775        if ( ! empty( $userdata['ID'] ) ) {
    1776                 $ID            = (int) $userdata['ID'];
     1776                $user_id       = (int) $userdata['ID'];
    17771777                $update        = true;
    1778                 $old_user_data = get_userdata( $ID );
     1778                $old_user_data = get_userdata( $user_id );
    17791779
    17801780                if ( ! $old_user_data ) {
     
    20322032         * }
    20332033         * @param bool     $update   Whether the user is being updated rather than created.
    2034          * @param int|null $id       ID of the user to be updated, or NULL if the user is being created.
     2034         * @param int|null $user_id  ID of the user to be updated, or NULL if the user is being created.
    20352035         * @param array    $userdata The raw array of data passed to wp_insert_user().
    20362036         */
    2037         $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, ( $update ? (int) $ID : null ), $userdata );
     2037        $data = apply_filters( 'wp_pre_insert_user_data', $data, $update, ( $update ? $user_id : null ), $userdata );
    20382038
    20392039        if ( empty( $data ) || ! is_array( $data ) ) {
     
    20452045                        $data['user_activation_key'] = '';
    20462046                }
    2047                 $wpdb->update( $wpdb->users, $data, compact( 'ID' ) );
    2048                 $user_id = (int) $ID;
     2047                $wpdb->update( $wpdb->users, $data, array( 'ID' => $user_id ) );
    20492048        } else {
    20502049                $wpdb->insert( $wpdb->users, $data );
     
    21782177        }
    21792178
    2180         $ID = isset( $userdata['ID'] ) ? (int) $userdata['ID'] : 0;
    2181         if ( ! $ID ) {
     2179        $user_id = isset( $userdata['ID'] ) ? (int) $userdata['ID'] : 0;
     2180        if ( ! $user_id ) {
    21822181                return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
    21832182        }
    21842183
    21852184        // First, get all of the original fields.
    2186         $user_obj = get_userdata( $ID );
     2185        $user_obj = get_userdata( $user_id );
    21872186        if ( ! $user_obj ) {
    21882187                return new WP_Error( 'invalid_user_id', __( 'Invalid user ID.' ) );
     
    21932192        // Add additional custom fields.
    21942193        foreach ( _get_additional_user_keys( $user_obj ) as $key ) {
    2195                 $user[ $key ] = get_user_meta( $ID, $key, true );
     2194                $user[ $key ] = get_user_meta( $user_id, $key, true );
    21962195        }
    21972196
     
    23742373        // Update the cookies if the password changed.
    23752374        $current_user = wp_get_current_user();
    2376         if ( $current_user->ID == $ID ) {
     2375        if ( $current_user->ID == $user_id ) {
    23772376                if ( isset( $plaintext_pass ) ) {
    23782377                        wp_clear_auth_cookie();
     
    23822381                        $logged_in_cookie = wp_parse_auth_cookie( '', 'logged_in' );
    23832382                        /** This filter is documented in wp-includes/pluggable.php */
    2384                         $default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $ID, false );
     2383                        $default_cookie_life = apply_filters( 'auth_cookie_expiration', ( 2 * DAY_IN_SECONDS ), $user_id, false );
    23852384                        $remember            = false;
    23862385                        if ( false !== $logged_in_cookie && ( $logged_in_cookie['expiration'] - time() ) > $default_cookie_life ) {
     
    23882387                        }
    23892388
    2390                         wp_set_auth_cookie( $ID, $remember );
     2389                        wp_set_auth_cookie( $user_id, $remember );
    23912390                }
    23922391        }
     
    25512550         * @since 2.7.0
    25522551         *
    2553          * @param bool $allow Whether to allow the password to be reset. Default true.
    2554          * @param int  $ID    The ID of the user attempting to reset a password.
     2552         * @param bool $allow   Whether to allow the password to be reset. Default true.
     2553         * @param int  $user_id The ID of the user attempting to reset a password.
    25552554         */
    25562555        $allow = apply_filters( 'allow_password_reset', $allow, $user->ID );
Note: See TracChangeset for help on using the changeset viewer.