Make WordPress Core


Ignore:
Timestamp:
03/29/2022 12:41:00 PM (3 years ago)
Author:
spacedmonkey
Message:

Users: Introduce the concept of a large site to single site installations.

Currently in WordPress multisite there is a concept of large networks. The function wp_is_large_network is used to determine if a network has a large number of sites or users. If a network is marked as large, then
expensive queries to calculate user counts are not run on page load but deferred to scheduled events. However there are a number of places in a single site installation where this functionality would also be useful, as
expensive calls to count users and roles can make screens in the admin extremely slow.

In this change, the get_user_count function and related functionality around it is ported to be available in a single site context. This means that expensive calls to the count_users function are replaced with
calls to get_user_count. This change also includes a new function called wp_is_large_user_count and a filter of the same name, to mark if a site is large.

Props johnbillion, Spacedmonkey, Mista-Flo, lumpysimon, tharsheblows, obenland, miss_jwo, jrchamp, flixos90, macbookandrew, pento, desrosj, johnjamesjacoby, jb510, davidbaumwald, costdev.
Fixes #38741.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-debug-data.php

    r53003 r53011  
    389389            }
    390390
    391             $info['wp-core']['fields']['user_count'] = array(
    392                 'label' => __( 'User count' ),
    393                 'value' => get_user_count(),
    394             );
    395 
    396391            $info['wp-core']['fields']['site_count'] = array(
    397392                'label' => __( 'Site count' ),
     
    403398                'value' => $network_query->found_networks,
    404399            );
    405         } else {
    406             $user_count = count_users();
    407 
    408             $info['wp-core']['fields']['user_count'] = array(
    409                 'label' => __( 'User count' ),
    410                 'value' => $user_count['total_users'],
    411             );
    412         }
     400        }
     401
     402        $info['wp-core']['fields']['user_count'] = array(
     403            'label' => __( 'User count' ),
     404            'value' => get_user_count(),
     405        );
    413406
    414407        // WordPress features requiring processing.
Note: See TracChangeset for help on using the changeset viewer.