[wp-trac] [WordPress Trac] #63045: Add caching to `count_many_users_posts()`

WordPress Trac noreply at wordpress.org
Fri Oct 17 19:49:07 UTC 2025


#63045: Add caching to `count_many_users_posts()`
-------------------------------------------------+-------------------------
 Reporter:  flixos90                             |       Owner:
                                                 |  peterwilsoncc
     Type:  enhancement                          |      Status:  reopened
 Priority:  normal                               |   Milestone:  6.9
Component:  Users                                |     Version:
 Severity:  normal                               |  Resolution:
 Keywords:  has-patch has-unit-tests needs-      |     Focuses:
  testing                                        |  performance
-------------------------------------------------+-------------------------
Changes (by spacedmonkey):

 * status:  closed => reopened
 * resolution:  fixed =>


Comment:

 @peterwilsoncc I would tweak the logic here.

 {{{#!php
    $where       = get_posts_by_author_sql( $post_type, true, null,
 $public_only );
    $query       = "SELECT post_author, COUNT(*) FROM $wpdb->posts $where
 AND post_author IN ($userlist) GROUP BY post_author";
    ...
    if ( false === $count ) {
         $result = $wpdb->get_results( $query, ARRAY_N );

 }}}

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


More information about the wp-trac mailing list