Make WordPress Core

Ticket #57023: 57023.diff

File 57023.diff, 2.3 KB (added by SergeyBiryukov, 16 months ago)
  • src/wp-includes/ms-blogs.php

     
    877877 * Handler for updating the current site's posts count when a post is deleted.
    878878 *
    879879 * @since 4.0.0
     880 * @since 6.2.0 Added the `$post` parameter.
    880881 *
    881  * @param int $post_id Post ID.
     882 * @param int     $post_id Post ID.
     883 * @param WP_Post $post    Post object.
    882884 */
    883 function _update_posts_count_on_delete( $post_id ) {
    884         $post = get_post( $post_id );
    885 
     885function _update_posts_count_on_delete( $post_id, $post ) {
    886886        if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
    887887                return;
    888888        }
  • src/wp-includes/ms-default-filters.php

     
    7575add_filter( 'allowed_redirect_hosts', 'redirect_this_site' );
    7676
    7777// Administration.
    78 add_action( 'after_delete_post', '_update_posts_count_on_delete' );
     78add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 );
    7979add_action( 'delete_post', '_update_blog_date_on_post_delete' );
    8080add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 );
    8181add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 );
  • tests/phpunit/tests/multisite/updatePostsCount.php

     
    3434                         */
    3535                        $this->assertSame( $original_post_count + 1, get_site()->post_count, 'Post count should be incremented by 1.' );
    3636
    37                         wp_delete_post( $post_id );
     37                        wp_delete_post( $post_id, true );
    3838
    3939                        /*
    4040                         * Check that posts count is updated when a post is deleted:
    41                          * add_action( 'deleted_post', '_update_posts_count_on_delete' );
     41                         * add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 );
    4242                         *
    4343                         * Check that _update_posts_count_on_delete() is called on that filter,
    4444                         * which then calls update_posts_count() to update the count.