Make WordPress Core


Ignore:
Timestamp:
03/29/2022 12:41:00 PM (2 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/upgrade.php

    r52662 r53011  
    846846    }
    847847
     848    if ( $wp_current_db_version < 53011 ) {
     849        upgrade_600();
     850    }
     851
    848852    maybe_disable_link_manager();
    849853
     
    22842288
    22852289/**
     2290 * Executes changes made in WordPress 6.0.0.
     2291 *
     2292 * @ignore
     2293 * @since 6.0.0
     2294 *
     2295 * @global int $wp_current_db_version The old (current) database version.
     2296 */
     2297function upgrade_600() {
     2298    global $wp_current_db_version;
     2299
     2300    if ( $wp_current_db_version < 53011 ) {
     2301        wp_update_user_counts();
     2302    }
     2303}
     2304
     2305/**
    22862306 * Executes network-level upgrade routines.
    22872307 *
Note: See TracChangeset for help on using the changeset viewer.