WordPress.org

Make WordPress Core

Ticket #29785: user_count.patch

File user_count.patch, 722 bytes (added by psoluch, 6 years ago)

Creates a joint query for users and user_meta tables in count_users() function

  • wp-includes/user.php

     
    11791179                $select_count = implode(', ', $select_count);
    11801180
    11811181                // Add the meta_value index to the selection list, then run the query.
    1182                 $row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
     1182                $row = $wpdb->get_row( "SELECT $select_count, COUNT(*) FROM $wpdb->usermeta JOIN $wpdb->users ON user_id = ID WHERE meta_key = '{$blog_prefix}capabilities'", ARRAY_N );
    11831183
    11841184                // Run the previous loop again to associate results with role names.
    11851185                $col = 0;