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. Built from https://develop.svn.wordpress.org/trunk@27152 git-svn-id: http://core.svn.wordpress.org/trunk@27019 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
805d6fe59b
commit
c2adc15b45
|
@ -275,11 +275,18 @@ function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
|
||||||
|
|
||||||
if ( $reassign != '' ) {
|
if ( $reassign != '' ) {
|
||||||
$reassign = (int) $reassign;
|
$reassign = (int) $reassign;
|
||||||
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
|
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $user_id ) );
|
||||||
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->links SET link_owner = %d WHERE link_owner = %d", $reassign, $user_id) );
|
$link_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->links WHERE link_owner = %d", $user_id ) );
|
||||||
|
|
||||||
$post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $reassign ) );
|
if ( ! empty( $post_ids ) ) {
|
||||||
array_map( 'clean_post_cache', $post_ids );
|
$wpdb->query( $wpdb->prepare( "UPDATE $wpdb->posts SET post_author = %d WHERE ID IN (" . implode( ',', $post_ids ) . ")", $reassign ) );
|
||||||
|
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 ) );
|
||||||
|
array_walk( $link_ids, 'clean_bookmark_cache' );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restore_current_blog();
|
restore_current_blog();
|
||||||
|
|
Loading…
Reference in New Issue