From 376748a097d6b3d283efff31790ddb6b49f3dc6e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Wed, 1 Mar 2023 15:39:27 +0000 Subject: [PATCH] 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 --- wp-includes/author-template.php | 5 +++-- wp-includes/version.php | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/wp-includes/author-template.php b/wp-includes/author-template.php index 2570a4035b..faeb6a89a0 100644 --- a/wp-includes/author-template.php +++ b/wp-includes/author-template.php @@ -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; } } diff --git a/wp-includes/version.php b/wp-includes/version.php index 31d25fd6e6..db827d850d 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-beta3-55443'; +$wp_version = '6.2-beta3-55444'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.