Make WordPress Core


Ignore:
Timestamp:
10/30/2017 07:55:09 PM (6 years ago)
Author:
flixos90
Message:

Multisite: Pass network object instead of ID to pre_get_main_site_id.

In the original function introduced in [41380], and subsequently [41861], only the network ID was passed to the new pre_get_main_site_id filter. In order to make give quick access to other network properties, it was decided to pass the whole object instead. The changeset includes an additional test.

Fixes #29684.

File:
1 edited

Legend:

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

    r41861 r42043  
    108108
    109109    /**
     110     * @ticket 29684
     111     */
     112    public function test_get_main_site_id_filtered_depending_on_network() {
     113        add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id_depending_on_network' ), 10, 2 );
     114        $result = get_main_site_id( self::$network_ids['wordpress.org/'] );
     115
     116        $this->assertSame( 333, $result );
     117    }
     118
     119    public function filter_get_main_site_id_depending_on_network( $main_site_id, $network ) {
     120        // Override main site ID for a specific network for the test.
     121        if ( $network->id === (int) self::$network_ids['wordpress.org/'] ) {
     122            return 333;
     123        }
     124
     125        return $main_site_id;
     126    }
     127
     128    /**
    110129     * @ticket 41936
    111130     */
Note: See TracChangeset for help on using the changeset viewer.