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/default-filters.php

    r41361 r41613  
    467467add_action( 'init', 'wp_widgets_init', 1 );
    468468
     469// User counts
     470foreach ( array( 'user_register', 'deleted_user' ) as $action ){
     471    add_action( $action, 'wp_update_active_user_count' );
     472}
     473
    469474// Admin Bar
    470475// Don't remove. Wrong way to disable.
Note: See TracChangeset for help on using the changeset viewer.