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:
parent
13195cfe8e
commit
376748a097
|
@ -481,14 +481,15 @@ function wp_list_authors( $args = '' ) {
|
||||||
$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args );
|
$post_counts = apply_filters( 'pre_wp_list_authors_post_counts_query', false, $parsed_args );
|
||||||
|
|
||||||
if ( ! is_array( $post_counts ) ) {
|
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
|
"SELECT DISTINCT post_author, COUNT(ID) AS count
|
||||||
FROM $wpdb->posts
|
FROM $wpdb->posts
|
||||||
WHERE " . get_private_posts_cap_sql( 'post' ) . '
|
WHERE " . get_private_posts_cap_sql( 'post' ) . '
|
||||||
GROUP BY post_author'
|
GROUP BY post_author'
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach ( (array) $post_counts as $row ) {
|
foreach ( (array) $post_counts_query as $row ) {
|
||||||
$post_counts[ $row->post_author ] = $row->count;
|
$post_counts[ $row->post_author ] = $row->count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue