WordPress.org

Make WordPress Core

Changeset 20522


Ignore:
Timestamp:
04/18/12 21:07:31 (3 years ago)
Author:
duck_
Message:

Pass full user objects to clean_user_cache(). See #19500, fixes #20460.

Prevents notices when clean_user_cache() is called for a user that has been removed from the database.

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/ms.php

    r20289 r20522  
    133133 
    134134    $id = (int) $id; 
     135    $user = new WP_User( $id ); 
    135136 
    136137    do_action( 'wpmu_delete_user', $id ); 
     
    163164    $wpdb->delete( $wpdb->usermeta, array( 'user_id' => $id ) ); 
    164165 
    165     clean_user_cache( $id ); 
     166    clean_user_cache( $user ); 
    166167 
    167168    // allow for commit transaction 
     
    390391    $wpdb->update( $wpdb->users, array( $pref => $value ), array( 'ID' => $id ) ); 
    391392 
    392     clean_user_cache( $id ); 
     393    $user = new WP_User( $id ); 
     394    clean_user_cache( $user ); 
    393395 
    394396    if ( $pref == 'spam' ) { 
     
    408410        return false; 
    409411 
    410     clean_user_cache( $id ); 
     412    clean_user_cache( $user ); 
    411413 
    412414    return $id; 
  • trunk/wp-admin/includes/user.php

    r20287 r20522  
    238238 
    239239    $id = (int) $id; 
     240    $user = new WP_User( $id ); 
    240241 
    241242    // allow for transaction statement 
     
    263264    } 
    264265 
    265     clean_user_cache($id); 
     266    clean_user_cache( $user ); 
    266267 
    267268    // FINALLY, delete user 
  • trunk/wp-includes/user.php

    r20378 r20522  
    11441144 * @since 3.0.0 
    11451145 * 
    1146  * @param int $id User ID 
    1147  */ 
    1148 function clean_user_cache($id) { 
    1149     $user = WP_User::get_data_by( 'id', $id ); 
    1150  
    1151     wp_cache_delete($id, 'users'); 
    1152     wp_cache_delete($user->user_login, 'userlogins'); 
    1153     wp_cache_delete($user->user_email, 'useremail'); 
    1154     wp_cache_delete($user->user_nicename, 'userslugs'); 
     1146 * @param WP_User $user User object to be cleaned from the cache 
     1147 */ 
     1148function clean_user_cache( $user ) { 
     1149    if ( is_numeric( $user ) ) { 
     1150        _deprecated_argument( __FUNCTION__, '3.4', 'Pass the full user object instead of the ID.' ); 
     1151        $user = new WP_User( $user ); 
     1152    } 
     1153 
     1154    if ( ! $user->exists() ) 
     1155        return; 
     1156 
     1157    wp_cache_delete( $user->ID, 'users' ); 
     1158    wp_cache_delete( $user->user_login, 'userlogins' ); 
     1159    wp_cache_delete( $user->user_email, 'useremail' ); 
     1160    wp_cache_delete( $user->user_nicename, 'userslugs' ); 
    11551161} 
    11561162 
Note: See TracChangeset for help on using the changeset viewer.