WordPress.org

Make WordPress Core

Ticket #42021: 42021.patch

File 42021.patch, 1.8 KB (added by JPry, 3 years ago)

Tweaks to @sboisvert 's patch

  • src/wp-includes/ms-blogs.php

    diff --git src/wp-includes/ms-blogs.php src/wp-includes/ms-blogs.php
    index edfb0e4443..c62e5b72eb 100644
    function _update_posts_count_on_delete( $post_id ) { 
    12991299 *
    13001300 * @since 4.0.0
    13011301 *
    1302  * @param string $new_status The status the post is changing to.
    1303  * @param string $old_status The status the post is changing from.
     1302 * @param string  $new_status The status the post is changing to.
     1303 * @param string  $old_status The status the post is changing from.
     1304 * @param WP_Post $post       Post object
    13041305 */
    1305 function _update_posts_count_on_transition_post_status( $new_status, $old_status ) {
     1306function _update_posts_count_on_transition_post_status( $new_status, $old_status, $post ) {
    13061307        if ( $new_status === $old_status ) {
    13071308                return;
    13081309        }
    13091310
     1311        // update_posts_count() only looks for the 'post' post type, so skip any other type.
     1312        if ( 'post' !== $post->post_type ) {
     1313                return;
     1314        }
     1315
    13101316        if ( 'publish' !== $new_status && 'publish' !== $old_status ) {
    13111317                return;
    13121318        }
  • src/wp-includes/ms-default-filters.php

    diff --git src/wp-includes/ms-default-filters.php src/wp-includes/ms-default-filters.php
    index 3d81e4cec7..fe66f0aa77 100644
    add_filter( 'term_id_filter', 'global_terms', 10, 2 ); 
    5454add_action( 'delete_post', '_update_posts_count_on_delete' );
    5555add_action( 'delete_post', '_update_blog_date_on_post_delete' );
    5656add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
    57 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 2 );
     57add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
    5858
    5959// Counts
    6060add_action( 'admin_init', 'wp_schedule_update_network_counts');