Ticket #40349: 40349.2.diff
File 40349.2.diff, 2.1 KB (added by , 8 years ago) |
---|
-
src/wp-includes/ms-functions.php
2354 2354 * Update the network-wide user count. 2355 2355 * 2356 2356 * @since 3.7.0 2357 * @since 4.8.0 The $network_id parameter has been added. 2357 2358 * 2358 2359 * @global wpdb $wpdb WordPress database abstraction object. 2360 * 2361 * @param int|null $network_id ID of the network. Default is the current network. 2359 2362 */ 2360 function wp_update_network_user_counts( ) {2363 function wp_update_network_user_counts( $network_id = null ) { 2361 2364 global $wpdb; 2362 2365 2363 2366 $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 2364 update_ site_option('user_count', $count );2367 update_network_option( $network_id, 'user_count', $count ); 2365 2368 } 2366 2369 2367 2370 /** -
tests/phpunit/tests/multisite/network.php
408 408 $result = get_blog_count( self::$different_network_id ); 409 409 $this->assertEquals( 3, $result ); 410 410 } 411 412 /** 413 * @ticket 40349 414 */ 415 public function test_wp_update_network_user_counts() { 416 global $wpdb; 417 418 update_network_option( null, 'user_count', 40 ); 419 420 $expected = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 421 422 wp_update_network_user_counts(); 423 424 $result = get_user_count(); 425 $this->assertEquals( $expected, $result ); 426 } 427 428 /** 429 * @ticket 40349 430 */ 431 public function test_wp_update_network_user_counts_on_different_network() { 432 global $wpdb; 433 434 update_network_option( self::$different_network_id, 'user_count', 40 ); 435 436 $expected = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" ); 437 438 wp_update_network_user_counts( self::$different_network_id ); 439 440 $result = get_user_count( self::$different_network_id ); 441 $this->assertEquals( $expected, $result ); 442 } 411 443 } 412 444 413 445 endif;