Prevent unnecessary $wpdb->update() when hierarchical post doesn't have children.

Props danielbachhuber.
Fixes #34896.

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


git-svn-id: http://core.svn.wordpress.org/trunk@35781 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Joe Hoyle 2015-12-07 17:47:25 +00:00
parent b6a14367e4
commit 5031ca5c23
2 changed files with 4 additions and 3 deletions

View File

@ -2405,9 +2405,10 @@ function wp_delete_post( $postid = 0, $force_delete = false ) {
// 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 = %s", $postid, $post->post_type );
$children = $wpdb->get_results( $children_query );
if ( $children ) {
$wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
}
}
// Do raw query. wp_get_post_revisions() is filtered.
$revision_ids = $wpdb->get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'revision'", $postid ) );

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.5-alpha-35816';
$wp_version = '4.5-alpha-35817';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.