Make WordPress Core

Changeset 27152


Ignore:
Timestamp:
02/09/2014 09:46:43 PM (11 years ago)
Author:
wonderboymusic
Message:

Collect the post and link ids that will be reassigned before running the update in remove_user_from_blog(). Use array_walk() instead of array_map() when invalidating the caches for the collected ids.

Props kovshenin.
Fixes #25545.

File:
1 edited

Legend:

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

    r27087 r27152  
    276276    if ( $reassign != '' ) {
    277277        $reassign = (int) $reassign;
    278         $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
    279         $wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) );
    280 
    281         $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $reassign ) );
    282         array_map( 'clean_post_cache', $post_ids );
     278        $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
     279        $link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
     280
     281        if ( ! empty( $post_ids ) ) {
     282            $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE ID IN (" . implode( ',', $post_ids ) . ")", $reassign ) );
     283            array_walk( $post_ids, 'clean_post_cache' );
     284        }
     285
     286        if ( ! empty( $link_ids ) ) {
     287            $wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE ID IN (" . implode( ',', $link_ids ) . ")", $reassign ) );
     288            array_walk( $link_ids, 'clean_bookmark_cache' );
     289        }
    283290    }
    284291
Note: See TracChangeset for help on using the changeset viewer.