Make WordPress Core


Ignore:
Timestamp:
12/07/2015 05:46:35 PM (10 years ago)
Author:
joehoyle
Message:

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

Props danielbachhuber.
Fixes #34896.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r35800 r35817  
    24062406        $children_query = $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_parent = %d AND post_type = %s", $postid, $post->post_type );
    24072407        $children = $wpdb->get_results( $children_query );
    2408 
    2409         $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
     2408        if ( $children ) {
     2409            $wpdb->update( $wpdb->posts, $parent_data, $parent_where + array( 'post_type' => $post->post_type ) );
     2410        }
    24102411    }
    24112412
Note: See TracChangeset for help on using the changeset viewer.