Posts, Post Types: Ensure that all post stati are countable in wp_count_posts.

When `wp_count_posts()` is cached, it does so with all statuses defaulted to 0. The problem is however, if this is called before all plugins have registered their desired statuses, they won't have that default.

Fixes #49685.

Props obliviousharmony, SergeyBiryukov.



git-svn-id: https://develop.svn.wordpress.org/trunk@48497 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jake Spurlock
2020-07-16 21:42:48 +00:00
parent ceccb7b3b1
commit 082cb0ab20
2 changed files with 23 additions and 0 deletions
+16
View File
@@ -879,6 +879,22 @@ class Tests_Post extends WP_UnitTestCase {
$this->assertNotEquals( $initial_counts->publish, $after_trash_counts->publish );
}
/**
* @ticket 49685
*/
function test_wp_count_posts_status_changes_visible() {
self::factory()->post->create_many( 3 );
// Trigger a cache.
wp_count_posts();
register_post_status( 'test' );
$counts = wp_count_posts();
$this->assertTrue( isset( $counts->test ) );
$this->assertEquals( 0, $counts->test );
}
/**
* @ticket 13771
*/