WordPress.org

Make WordPress Core

Changeset 12766


Ignore:
Timestamp:
01/19/2010 07:23:11 PM (12 years ago)
Author:
ryan
Message:

Introduce clean_user_cache(). fixes #11761

Location:
trunk
Files:
3 edited

Legend:

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

    r12765 r12766  
    102102}
    103103
     104// @todo Merge with wp_delete_user() ?
    104105function wpmu_delete_user($id) {
    105106    global $wpdb;
     
    132133    $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d", $id) );
    133134
    134     wp_cache_delete($id, 'users');
    135     wp_cache_delete($user->user_login, 'userlogins');
     135    clean_user_cache($id); 
     136
     137    // allow for commit transaction
     138    do_action('deleted_user', $id);
    136139
    137140    return true;
     
    450453        return false;
    451454
    452     wp_cache_delete($id, 'users');
    453     wp_cache_delete($user->user_login, 'userlogins');
     455    clean_user_cache($id);
     456
    454457    return $id;
    455458}
  • trunk/wp-admin/includes/user.php

    r12755 r12766  
    420420 * @return bool True when finished.
    421421 */
    422 function wp_delete_user($id, $reassign = 'novalue') {
     422function wp_delete_user( $id, $reassign = 'novalue' ) {
    423423    global $wpdb;
    424424
     
    429429    do_action('delete_user', $id);
    430430
    431     if ($reassign == 'novalue') {
     431    if ( 'novalue' === $reassign || null === $reassign ) {
    432432        $post_ids = $wpdb->get_col( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id) );
    433433
    434         if ($post_ids) {
    435             foreach ($post_ids as $post_id)
     434        if ( $post_ids ) {
     435            foreach ( $post_ids as $post_id )
    436436                wp_delete_post($post_id);
    437437        }
     
    444444                wp_delete_link($link_id);
    445445        }
    446 
    447446    } else {
    448447        $reassign = (int) $reassign;
     
    460459    }
    461460
    462     wp_cache_delete($id, 'users');
    463     wp_cache_delete($user->user_login, 'userlogins');
    464     wp_cache_delete($user->user_email, 'useremail');
    465     wp_cache_delete($user->user_nicename, 'userslugs');
     461    clean_user_cache($id);
    466462
    467463    // allow for commit transaction
  • trunk/wp-includes/user.php

    r12733 r12766  
    736736}
    737737
     738/**
     739 * Clean all user caches
     740 *
     741 * @since 3.0
     742 *
     743 * @param int $id User ID
     744 * @return void
     745 */
     746function clean_user_cache($id) {
     747    $user = new WP_User($id);
     748
     749    wp_cache_delete($id, 'users');
     750    wp_cache_delete($user->user_login, 'userlogins');
     751    wp_cache_delete($user->user_email, 'useremail');
     752    wp_cache_delete($user->user_nicename, 'userslugs');
     753}
     754
    738755?>
Note: See TracChangeset for help on using the changeset viewer.