Ticket #57023: 57023.diff
File 57023.diff, 2.3 KB (added by , 2 years ago) |
---|
-
src/wp-includes/ms-blogs.php
877 877 * Handler for updating the current site's posts count when a post is deleted. 878 878 * 879 879 * @since 4.0.0 880 * @since 6.2.0 Added the `$post` parameter. 880 881 * 881 * @param int $post_id Post ID. 882 * @param int $post_id Post ID. 883 * @param WP_Post $post Post object. 882 884 */ 883 function _update_posts_count_on_delete( $post_id ) { 884 $post = get_post( $post_id ); 885 885 function _update_posts_count_on_delete( $post_id, $post ) { 886 886 if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) { 887 887 return; 888 888 } -
src/wp-includes/ms-default-filters.php
75 75 add_filter( 'allowed_redirect_hosts', 'redirect_this_site' ); 76 76 77 77 // Administration. 78 add_action( 'after_delete_post', '_update_posts_count_on_delete' );78 add_action( 'after_delete_post', '_update_posts_count_on_delete', 10, 2 ); 79 79 add_action( 'delete_post', '_update_blog_date_on_post_delete' ); 80 80 add_action( 'transition_post_status', '_update_blog_date_on_post_publish', 10, 3 ); 81 81 add_action( 'transition_post_status', '_update_posts_count_on_transition_post_status', 10, 3 ); -
tests/phpunit/tests/multisite/updatePostsCount.php
34 34 */ 35 35 $this->assertSame( $original_post_count + 1, get_site()->post_count, 'Post count should be incremented by 1.' ); 36 36 37 wp_delete_post( $post_id );37 wp_delete_post( $post_id, true ); 38 38 39 39 /* 40 40 * 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 ); 42 42 * 43 43 * Check that _update_posts_count_on_delete() is called on that filter, 44 44 * which then calls update_posts_count() to update the count.