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. Built from https://develop.svn.wordpress.org/trunk@55444 git-svn-id: http://core.svn.wordpress.org/trunk@54977 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -481,14 +481,15 @@ function wp_list_authors( $args = '' ) {
|
||||
$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args );
|
||||
|
||||
if ( ! is_array( $post_counts ) ) {
|
||||
$post_counts = $wpdb->get_results(
|
||||
$post_counts = array();
|
||||
$post_counts_query = $wpdb->get_results(
|
||||
"SELECT DISTINCT post_author, COUNT(ID) AS count
|
||||
FROM $wpdb->posts
|
||||
WHERE " . get_private_posts_cap_sql( 'post' ) . '
|
||||
GROUP BY post_author'
|
||||
);
|
||||
|
||||
foreach ( (array) $post_counts as $row ) {
|
||||
foreach ( (array) $post_counts_query as $row ) {
|
||||
$post_counts[ $row->post_author ] = $row->count;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user