mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-11 12:20:22 +00:00
Users: Use a separate variable for the post counts query in wp_list_authors().
This avoids a collision if `wp_list_authors()` is called with the `optioncount` parameter enabled, and the resulting array for the post counts query contains a key that matches the ID of a user who does not have any posts. Follow-up to [54262]. Props peterwilsoncc, johnbillion, lifeboat, brookedot, thedaysse, Toru. Fixes #57011. git-svn-id: https://develop.svn.wordpress.org/trunk@55444 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -146,6 +146,31 @@ class Tests_User_wpListAuthors extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures the 'optioncount' parameter does not throw an error when there are authors without posts.
|
||||
*
|
||||
* @ticket 57011
|
||||
*/
|
||||
public function test_wp_list_authors_optioncount_should_not_error_for_empty_authors() {
|
||||
/*
|
||||
* The main purpose of this test is to ensure that the error below is not thrown:
|
||||
*
|
||||
* Error: Object of class stdClass could not be converted to string
|
||||
*
|
||||
* In place of direct testing we ensure `wp_list_authors()` returns a list of authors
|
||||
* at least one of which is empty.
|
||||
*/
|
||||
$actual = wp_list_authors(
|
||||
array(
|
||||
'optioncount' => true,
|
||||
'hide_empty' => false,
|
||||
'exclude_admin' => false,
|
||||
'echo' => false,
|
||||
)
|
||||
);
|
||||
$this->assertStringContainsString( '(0)', $actual );
|
||||
}
|
||||
|
||||
public function test_wp_list_authors_exclude_admin() {
|
||||
self::factory()->post->create(
|
||||
array(
|
||||
|
||||
Reference in New Issue
Block a user