mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Multisite: Take WP_Network::$blog_id into account in get_main_site_id().
When the `WP_Network::$blog_id` property is set manually, for example in the multisite bootstrap process, `get_main_site_id()` should use that value instead of running its own logic. The main logic for the function was therefore moved into the internal `WP_Network::get_main_site_id()` method, which is now being accessed by the function through the magic property handling for `WP_Network::$blog_id` (and its equivalent `WP_Network::$site_id`). Props spacedmonkey, jeremyfelt. Fixes #41936. git-svn-id: https://develop.svn.wordpress.org/trunk@41861 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -105,6 +105,39 @@ class Tests_Multisite_Get_Main_Site_ID extends WP_UnitTestCase {
|
||||
public function filter_get_main_site_id() {
|
||||
return 333;
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 41936
|
||||
*/
|
||||
public function test_get_main_site_id_with_property_value() {
|
||||
global $current_site;
|
||||
|
||||
$original_main_site_id = $current_site->blog_id;
|
||||
$current_site->blog_id = '123';
|
||||
|
||||
$result = get_main_site_id();
|
||||
|
||||
$current_site->blog_id = $original_main_site_id;
|
||||
|
||||
$this->assertSame( 123, $result );
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 41936
|
||||
*/
|
||||
public function test_get_main_site_id_filtered_with_property_value() {
|
||||
global $current_site;
|
||||
|
||||
$original_main_site_id = $current_site->blog_id;
|
||||
$current_site->blog_id = '123';
|
||||
|
||||
add_filter( 'pre_get_main_site_id', array( $this, 'filter_get_main_site_id' ) );
|
||||
$result = get_main_site_id();
|
||||
|
||||
$current_site->blog_id = $original_main_site_id;
|
||||
|
||||
$this->assertSame( 333, $result );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
Reference in New Issue
Block a user