Make WordPress Core


Ignore:
Timestamp:
09/27/2017 01:03:03 PM (8 years ago)
Author:
johnbillion
Message:

Users: Introduce the concept of a large site in order to speed up the Users screen when there are many users.

Calling the count_users() function is expensive, regardless of the counting strategy that's used, and it gets
slower the more users there are on a site. In order to speed up the Users screen in the admin area, calling
count_users() can be avoided entirely while still displaying the total count for users.

This introduces some new functions:

  • wp_is_large_user_count()
  • wp_get_active_user_count()
  • wp_update_active_user_count()

A corresponding wp_is_large_user_count filter is also introduced.

Props tharsheblows, johnbillion

Fixes #38741

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r41596 r41613  
    25542554    if ( 'users' == $using ) {
    25552555        $count = get_user_count( $network_id );
     2556        $is_large = ( $count > 10000 );
     2557
     2558        /** This filter is documented in wp-includes/functions.php */
     2559        $is_large = apply_filters( 'wp_is_large_user_count', $is_large, $count );
     2560
    25562561        /**
    25572562         * Filters whether the network is considered large.
     
    25652570         * @param int    $network_id       The ID of the network being checked.
    25662571         */
    2567         return apply_filters( 'wp_is_large_network', $count > 10000, 'users', $count, $network_id );
     2572        return apply_filters( 'wp_is_large_network', $is_large, 'users', $count, $network_id );
    25682573    }
    25692574
Note: See TracChangeset for help on using the changeset viewer.