Make WordPress Core


Ignore:
Timestamp:
04/19/2017 11:59:16 PM (8 years ago)
Author:
flixos90
Message:

Multisite: Add $network_id parameter to wp_update_network_site_counts().

Using the new parameter, it is now possible to update the site counts on a network different from the current network.

Props PieWP, johnjamesjacoby.
Fixes #37528. See #38699.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tests/phpunit/tests/multisite/network.php

    r40371 r40484  
    377377        $this->assertEquals( $blog_id, $dashboard_blog->blog_id );
    378378    }
     379
     380    /**
     381     * @ticket 37528
     382     */
     383    function test_wp_update_network_site_counts() {
     384        update_network_option( null, 'blog_count', 40 );
     385
     386        $expected = get_sites( array(
     387            'network_id' => get_current_network_id(),
     388            'spam'       => 0,
     389            'deleted'    => 0,
     390            'archived'   => 0,
     391            'count'      => true,
     392        ) );
     393
     394        wp_update_network_site_counts();
     395
     396        $result = get_blog_count();
     397        $this->assertEquals( $expected, $result );
     398    }
     399
     400    /**
     401     * @ticket 37528
     402     */
     403    function test_wp_update_network_site_counts_on_different_network() {
     404        update_network_option( self::$different_network_id, 'blog_count', 40 );
     405
     406        wp_update_network_site_counts( self::$different_network_id );
     407
     408        $result = get_blog_count( self::$different_network_id );
     409        $this->assertEquals( 3, $result );
     410    }
    379411}
    380412
Note: See TracChangeset for help on using the changeset viewer.