Skip to content

Commit 7966b89

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@40486 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d6297c0 commit 7966b89

2 files changed

Lines changed: 36 additions & 3 deletions

File tree

src/wp-includes/ms-functions.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,10 +2274,13 @@ function wp_schedule_update_network_counts() {
22742274
* Update the network-wide counts for the current network.
22752275
*
22762276
* @since 3.1.0
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.
22772280
*/
2278-
function wp_update_network_counts() {
2279-
wp_update_network_user_counts();
2280-
wp_update_network_site_counts();
2281+
function 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

22832286
/**

tests/phpunit/tests/multisite/network.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,36 @@ public function test_wp_update_network_user_counts_on_different_network() {
440440
$result = get_user_count( self::$different_network_id );
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

445475
endif;

0 commit comments

Comments
 (0)