clean page cache when reparenting pages after deletion. Props hailin. fixes #5457
git-svn-id: https://develop.svn.wordpress.org/trunk@6382 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c5df163698
commit
390e3d1c20
@ -758,7 +758,10 @@ function wp_delete_post($postid = 0) {
|
|||||||
delete_option('page_for_posts');
|
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' ) );
|
$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 ) {
|
if ( 'page' == $post->post_type ) {
|
||||||
clean_page_cache($postid);
|
clean_page_cache($postid);
|
||||||
|
|
||||||
|
foreach ( (array) $children as $child )
|
||||||
|
clean_page_cache($child->ID);
|
||||||
|
|
||||||
$wp_rewrite->flush_rules();
|
$wp_rewrite->flush_rules();
|
||||||
} else {
|
} else {
|
||||||
clean_post_cache($postid);
|
clean_post_cache($postid);
|
||||||
|
Loading…
Reference in New Issue
Block a user