Multisite: Add `$network_id` parameter to `wp_update_network_user_counts()`.

Using the new parameter, it is now possible to update the user count on a network different from the current one. While the count itself is technically a global user count and not network-wide, it is stored on each individual network, and the new parameter provides more control about where to update the count.

Fixes #40349. See #38699.

Built from https://develop.svn.wordpress.org/trunk@40485


git-svn-id: http://core.svn.wordpress.org/trunk@40361 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Felix Arntz 2017-04-20 00:14:43 +00:00
parent 7fa610b34a
commit 79be8dff6d
2 changed files with 6 additions and 3 deletions

View File

@ -2354,14 +2354,17 @@ function wp_update_network_site_counts( $network_id = null ) {
* Update the network-wide user count. * Update the network-wide user count.
* *
* @since 3.7.0 * @since 3.7.0
* @since 4.8.0 The $network_id parameter has been added.
* *
* @global wpdb $wpdb WordPress database abstraction object. * @global wpdb $wpdb WordPress database abstraction object.
*
* @param int|null $network_id ID of the network. Default is the current network.
*/ */
function wp_update_network_user_counts() { function wp_update_network_user_counts( $network_id = null ) {
global $wpdb; global $wpdb;
$count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
update_site_option( 'user_count', $count ); update_network_option( $network_id, 'user_count', $count );
} }
/** /**

View File

@ -4,7 +4,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '4.8-alpha-40484'; $wp_version = '4.8-alpha-40485';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.