mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 21:00:21 +00:00
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:
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user