In `remove_user_from_blog()`, avoid a potentially expensive `IN` query before invalidating the reassigned post and link caches.

Props kovshenin.
Fixes #25545. (Again.)


Built from https://develop.svn.wordpress.org/trunk@27161


git-svn-id: http://core.svn.wordpress.org/trunk@27027 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-02-11 16:28:13 +00:00
parent 0f360e10a3
commit f307aa1eb8
1 changed files with 2 additions and 2 deletions

View File

@ -279,12 +279,12 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
if ( ! empty( $post_ids ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE ID IN (" . implode( ',', $post_ids ) . ")", $reassign ) );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id ) );
array_walk( $post_ids, 'clean_post_cache' );
}
if ( ! empty( $link_ids ) ) {
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE ID IN (" . implode( ',', $link_ids ) . ")", $reassign ) );
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id ) );
array_walk( $link_ids, 'clean_bookmark_cache' );
}
}