Make WordPress Core

Ticket #40349: 40349.diff

File 40349.diff, 1.5 KB (added by flixos90, 8 years ago)
  • src/wp-includes/ms-functions.php

     
    23462346 * Update the network-wide user count.
    23472347 *
    23482348 * @since 3.7.0
     2349 * @since 4.8.0 The $network_id parameter has been added.
    23492350 *
    23502351 * @global wpdb $wpdb WordPress database abstraction object.
     2352 *
     2353 * @param int|null $network_id ID of the network. Default is the current network.
    23512354 */
    2352 function wp_update_network_user_counts() {
     2355function wp_update_network_user_counts( $network_id = null ) {
    23532356        global $wpdb;
    23542357
    23552358        $count = $wpdb->get_var( "SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'" );
    2356         update_site_option( 'user_count', $count );
     2359        update_network_option( $network_id, 'user_count', $count );
    23572360}
    23582361
    23592362/**
  • tests/phpunit/tests/multisite/network.php

     
    235235        }
    236236
    237237        /**
     238         * @ticket 40349
     239         */
     240        public function test_wp_update_network_user_counts_on_different_network() {
     241                wp_update_network_user_counts();
     242                $expected = get_user_count();
     243
     244                wp_update_network_user_counts( self::$different_network_id );
     245                $actual = get_user_count( self::$different_network_id );
     246
     247                $this->assertEquals( $expected, $actual );
     248        }
     249
     250        /**
    238251         * @ticket 22917
    239252         */
    240253        function test_enable_live_network_user_counts_filter() {