Ticket #37866: 37866.3.diff
File 37866.3.diff, 1.9 KB (added by , 8 years ago) |
---|
-
src/wp-includes/ms-functions.php
96 96 * The count is cached and updated twice daily. This is not a live count. 97 97 * 98 98 * @since MU 2.7 99 * @since 4.8.0 The $network_id parameter has been added. 99 100 * 100 * @return int 101 * @param int|null $network_id ID of the network. Default is the current network. 102 * @return int Number of active users on the network. 101 103 */ 102 function get_user_count( ) {103 return get_ site_option('user_count' );104 function get_user_count( $network_id = null ) { 105 return get_network_option( $network_id, 'user_count' ); 104 106 } 105 107 106 108 /** -
tests/phpunit/tests/multisite/network.php
206 206 } 207 207 208 208 /** 209 * @ticket 37866 210 */ 211 public function test_get_user_count_on_different_network() { 212 global $current_site, $wpdb; 213 214 wp_update_network_user_counts(); 215 $current_network_user_count = get_user_count(); 216 217 // switch_to_network()... 218 $orig_network_id = $current_site->id; 219 $orig_wpdb_network_id = $wpdb->siteid; 220 $current_site->id = self::$different_network_id; 221 $wpdb->siteid = self::$different_network_id; 222 223 // Add another user to fake the network user count to be different. 224 wpmu_create_user( 'user', 'pass', 'email' ); 225 226 wp_update_network_user_counts(); 227 228 // restore_current_network()... 229 $current_site->id = $orig_network_id; 230 $wpdb->siteid = $orig_wpdb_network_id; 231 232 $user_count = get_user_count( self::$different_network_id ); 233 234 $this->assertEquals( $current_network_user_count + 1, $user_count ); 235 } 236 237 /** 209 238 * @ticket 22917 210 239 */ 211 240 function test_enable_live_network_user_counts_filter() {