Make WordPress Core

Changeset 43382


Ignore:
Timestamp:
06/26/2018 04:29:33 PM (6 years ago)
Author:
flixos90
Message:

Multisite: Count users in a more performant way when listing sites in the network admin.

Props spacedmonkey.
Fixes #44368.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r42872 r43382  
    407407        $user_count = wp_cache_get( $blog['blog_id'] . '_user_count', 'blog-details' );
    408408        if ( ! $user_count ) {
    409             $blog_users = get_users(
    410                 array(
    411                     'blog_id' => $blog['blog_id'],
    412                     'fields'  => 'ID',
    413                 )
    414             );
    415             $user_count = count( $blog_users );
    416             unset( $blog_users );
     409            $blog_users = new WP_User_Query( array(
     410                'blog_id'     => $blog['blog_id'],
     411                'fields'      => 'ID',
     412                'number'      => 1,
     413                'count_total' => true,
     414            ) );
     415            $user_count = $blog_users->get_total();
    417416            wp_cache_set( $blog['blog_id'] . '_user_count', $user_count, 'blog-details', 12 * HOUR_IN_SECONDS );
    418417        }
Note: See TracChangeset for help on using the changeset viewer.