WordPress.org

Make WordPress Core

Ticket #11399: 11399.sw.2.diff

File 11399.sw.2.diff, 3.4 KB (added by simonwheatley, 8 years ago)

Don't bother recursing into revisions when cleaning post caches, refactor wp_publish_post as a wrapper for wp_update_post, remove _save_post and associated add_action, don't recurse cleaning_post_caches in wp_delete_post

  • wp-includes/default-filters.php

     
    249249add_action( 'shutdown',                   'wp_ob_end_flush_all',                      1    );
    250250add_action( 'pre_post_update',            'wp_save_post_revision'                          );
    251251add_action( 'publish_post',               '_publish_post_hook',                       5, 1 );
    252 add_action( 'save_post',                  '_save_post_hook',                          5, 2 );
    253252add_action( 'transition_post_status',     '_transition_post_status',                  5, 3 );
    254253add_action( 'transition_post_status',     '_update_term_count_on_transition_post_status', 10, 3 );
    255254add_action( 'comment_form',               'wp_comment_form_unfiltered_html_nonce'          );
  • wp-includes/post.php

     
    21002100
    21012101        clean_post_cache( $post );
    21022102
    2103         if ( is_post_type_hierarchical( $post->post_type ) ) {
    2104                 foreach ( (array) $children as $child )
    2105                         clean_post_cache( $child );
    2106         }
    2107 
    21082103        wp_clear_scheduled_hook('publish_future_post', array( $postid ) );
    21092104
    21102105        do_action('after_delete_post', $postid);
     
    27722767 * Publish a post by transitioning the post status.
    27732768 *
    27742769 * @since 2.1.0
    2775  * @uses $wpdb
    2776  * @uses do_action() Calls 'edit_post', 'save_post', and 'wp_insert_post' on post_id and post data.
     2770 * @uses wp_update_post()
    27772771 *
    2778  * @param int $post_id Post ID.
     2772 * @param int|object $post Post ID or Post object.
    27792773 * @return null
    27802774 */
    2781 function wp_publish_post($post_id) {
    2782         global $wpdb;
    2783 
    2784         $post = get_post($post_id);
    2785 
    2786         if ( empty($post) )
    2787                 return;
    2788 
    2789         if ( 'publish' == $post->post_status )
     2775function wp_publish_post($post) {
     2776        $post = get_post( $post );
     2777        if ( empty( $post ) )
    27902778                return;
    2791 
    2792         $wpdb->update( $wpdb->posts, array( 'post_status' => 'publish' ), array( 'ID' => $post_id ) );
    2793 
    2794         $old_status = $post->post_status;
    2795         $post->post_status = 'publish';
    2796         wp_transition_post_status('publish', $old_status, $post);
    2797 
    2798         do_action('edit_post', $post_id, $post);
    2799         do_action('save_post', $post_id, $post);
    2800         do_action('wp_insert_post', $post_id, $post);
     2779        wp_update_post( array( 'ID' => $post->ID, 'post_status' => 'publish' ) );
    28012780}
    28022781
    28032782/**
     
    44084387                do_action( 'clean_page_cache', $post->ID );
    44094388        }
    44104389
    4411         if ( $children = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_type FROM $wpdb->posts WHERE post_parent = %d", $post->ID) ) ) {
     4390        if ( $children = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_type FROM $wpdb->posts WHERE post_parent = %d AND post_type <> 'revision' ", $post->ID) ) ) {
    44124391                foreach ( $children as $child ) {
    44134392                        // Loop detection
    44144393                        if ( $child->ID == $post->ID )
     
    46154594}
    46164595
    46174596/**
    4618  * Hook used to prevent page/post cache from staying dirty when a post is saved.
    4619  *
    4620  * @since 2.3.0
    4621  * @access private
    4622  *
    4623  * @param int $post_id The ID in the database table for the $post
    4624  * @param object $post Object type containing the post information
    4625  */
    4626 function _save_post_hook( $post_id, $post ) {
    4627         clean_post_cache( $post );
    4628 }
    4629 
    4630 /**
    46314597 * Retrieve post ancestors and append to post ancestors property.
    46324598 *
    46334599 * Will only retrieve ancestors once, if property is already set, then nothing