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


git-svn-id: https://develop.svn.wordpress.org/trunk@41613 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
John Blackbourn
2017-09-27 13:03:03 +00:00
parent 0c1d3f62f3
commit 1507df9d59
6 changed files with 167 additions and 17 deletions
+1 -2
View File
@@ -78,8 +78,7 @@ function wp_version_check( $extra_stats = array(), $force_check = false ) {
$wp_install = network_site_url();
$multisite_enabled = 1;
} else {
$user_count = count_users();
$user_count = $user_count['total_users'];
$user_count = wp_get_active_user_count();
$multisite_enabled = 0;
$num_blogs = 1;
$wp_install = home_url( '/' );