Make WordPress Core

Changeset 40486


Ignore:
Timestamp:
04/20/2017 12:26:30 AM (9 years ago)
Author:
flixos90
Message:

Multisite: Add $network_id parameter to wp_update_network_counts().

After the $network_id parameter has been introduced for wp_update_network_site_counts() in [40484] and wp_update_network_user_counts() in [40485], the new parameter can now also be used on the wrapping function.

Fixes #40386. See #38699.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-functions.php

    r40485 r40486  
    22752275 *
    22762276 * @since 3.1.0
    2277  */
    2278 function wp_update_network_counts() {
    2279         wp_update_network_user_counts();
    2280         wp_update_network_site_counts();
     2277 * @since 4.8.0 The $network_id parameter has been added.
     2278 *
     2279 * @param int|null $network_id ID of the network. Default is the current network.
     2280 */
     2281function wp_update_network_counts( $network_id = null ) {
     2282        wp_update_network_user_counts( $network_id );
     2283        wp_update_network_site_counts( $network_id );
    22812284}
    22822285
  • trunk/tests/phpunit/tests/multisite/network.php

    r40485 r40486  
    441441                $this->assertEquals( $expected, $result );
    442442        }
     443
     444        /**
     445         * @ticket 40386
     446         */
     447        public function test_wp_update_network_counts() {
     448                delete_network_option( null, 'site_count' );
     449                delete_network_option( null, 'user_count' );
     450
     451                wp_update_network_counts();
     452
     453                $site_count = (int) get_blog_count();
     454                $user_count = (int) get_user_count();
     455
     456                $this->assertTrue( $site_count > 0 && $user_count > 0 );
     457        }
     458
     459        /**
     460         * @ticket 40386
     461         */
     462        public function test_wp_update_network_counts_on_different_network() {
     463                delete_network_option( self::$different_network_id, 'site_count' );
     464                delete_network_option( self::$different_network_id, 'user_count' );
     465
     466                wp_update_network_counts( self::$different_network_id );
     467
     468                $site_count = (int) get_blog_count( self::$different_network_id );
     469                $user_count = (int) get_user_count( self::$different_network_id );
     470
     471                $this->assertTrue( $site_count > 0 && $user_count > 0 );
     472        }
    443473}
    444474
Note: See TracChangeset for help on using the changeset viewer.