From 8f6268e38bdb60f21fb74320ba700218badd8c8c Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 14 Dec 2007 20:56:55 +0000 Subject: [PATCH] clean page cache when reparenting pages after deletion. Props hailin. fixes #5457 git-svn-id: http://svn.automattic.com/wordpress/trunk@6382 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/wp-includes/post.php b/wp-includes/post.php index 49822c98f9..a7a713d35a 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -758,7 +758,10 @@ function wp_delete_post($postid = 0) { delete_option('page_for_posts'); } - // Point children of this page to its parent + // Point children of this page to its parent, also clean the cache of affected children + $children_query = $wpdb->prepare("SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type='page'", $postid); + $children = $wpdb->get_results($children_query); + $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => 'page' ) ); } @@ -773,6 +776,10 @@ function wp_delete_post($postid = 0) { if ( 'page' == $post->post_type ) { clean_page_cache($postid); + + foreach ( (array) $children as $child ) + clean_page_cache($child->ID); + $wp_rewrite->flush_rules(); } else { clean_post_cache($postid);