From 3a5cf2395d65d7868d6df53029ce78488261658a Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Mon, 10 Sep 2012 19:56:08 +0000 Subject: [PATCH] When reassigning posts and links during user deletion, clear the post and link caches. Props kurtpayne. fixes #20447 git-svn-id: http://core.svn.wordpress.org/trunk@21798 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/user.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wp-admin/includes/user.php b/wp-admin/includes/user.php index f2143f2791..6a12ed072e 100644 --- a/wp-admin/includes/user.php +++ b/wp-admin/includes/user.php @@ -270,8 +270,18 @@ function wp_delete_user( $id, $reassign = 'novalue' ) { } } else { $reassign = (int) $reassign; + $post_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_author = %d", $id ) ); $wpdb->update( $wpdb->posts, array('post_author' => $reassign), array('post_author' => $id) ); + if ( ! empty( $post_ids ) ) { + foreach ( $post_ids as $post_id ) + clean_post_cache( $post_id ); + } + $link_ids = $wpdb->get_col( $wpdb->prepare("SELECT link_id FROM $wpdb->links WHERE link_owner = %d", $id) ); $wpdb->update( $wpdb->links, array('link_owner' => $reassign), array('link_owner' => $id) ); + if ( ! empty( $link_ids ) ) { + foreach ( $link_ids as $link_id ) + clean_bookmark_cache( $link_id ); + } } // FINALLY, delete user