From 79be8dff6d46b89aef2602e9bb626666024e59f5 Mon Sep 17 00:00:00 2001 From: Felix Arntz Date: Thu, 20 Apr 2017 00:14:43 +0000 Subject: [PATCH] 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 --- wp-includes/ms-functions.php | 7 +++++-- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index b2cbd63931..e024789052 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -2354,14 +2354,17 @@ function wp_update_network_site_counts( $network_id = null ) { * Update the network-wide user count. * * @since 3.7.0 + * @since 4.8.0 The $network_id parameter has been added. * * @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; $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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 3be5d05964..6b9e9f4b88 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @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.