[wp-trac] [WordPress Trac] #57011: wp_list_authors is broken in WordPress 6.1

WordPress Trac noreply at wordpress.org
Wed Nov 16 04:24:31 UTC 2022


#57011: wp_list_authors is broken in WordPress 6.1
--------------------------+------------------------------
 Reporter:  lifeboat      |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  General       |     Version:  6.1
 Severity:  normal        |  Resolution:
 Keywords:  has-patch     |     Focuses:
--------------------------+------------------------------

Comment (by peterwilsoncc):

 This looks to be related to [54262] for #17025.

 The variable name `$post_counts` is used for both the database query
 result and for storing the an array of counts keyed by the author's ID.

 {{{#!php
 <?php
 if ( ! is_array( $post_counts ) ) {
         $post_counts = $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 ) {
                 $post_counts[ $row->post_author ] = $row->count;
         }
 }
 }}}
 (extract from [https://github.com/WordPress/wordpress-
 develop/blob/6663deb7649a407a9bd98541d67552af8179bbc2/src/wp-includes
 /author-template.php#L483-L494 wp-includes/author-template.php])

 This results in an array mixing both the row objects and integers:

 {{{
 array(2) {
   [0] =>
   class stdClass#2234 (2) {
     public $post_author =>
     string(1) "1"
     public $count =>
     string(1) "4"
   }
   [1] =>
   string(1) "4"
 }
 }}}

 [attachment:"57011.diff"] renames the variable used for the database query
 to `$post_counts_query`.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/57011#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list