Multisite: Use get_network_option() for language in wpmu_create_blog().

Before this changeset, the language of a new site would always result in the language of the current network, regardless of the `$site_id` parameter passed that actually determines the network for the site. Now the correct `WPLANG` value is used in such cases.

Alongside this change, a few minor documentation changes around the function have been made to account for the current naming conventions of sites and networks.

Props spacedmonkey.
Fixes #40503.


git-svn-id: https://develop.svn.wordpress.org/trunk@41058 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Felix Arntz
2017-07-14 21:07:17 +00:00
parent e85f291a79
commit d18c6696c2
2 changed files with 42 additions and 5 deletions
+37
View File
@@ -10,6 +10,7 @@ if ( is_multisite() ) :
*/
class Tests_Multisite_Site extends WP_UnitTestCase {
protected $suppress = false;
protected static $network_ids;
function setUp() {
global $wpdb;
@@ -23,6 +24,26 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
parent::tearDown();
}
public static function wpSetUpBeforeClass( $factory ) {
self::$network_ids = array(
'make.wordpress.org/' => array( 'domain' => 'make.wordpress.org', 'path' => '/' ),
);
foreach ( self::$network_ids as &$id ) {
$id = $factory->network->create( $id );
}
unset( $id );
}
public static function wpTearDownAfterClass() {
global $wpdb;
foreach( self::$network_ids as $id ) {
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE site_id = %d", $id ) );
$wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->site} WHERE id= %d", $id ) );
}
}
function test_switch_restore_blog() {
global $_wp_switched_stack, $wpdb;
@@ -980,6 +1001,22 @@ class Tests_Multisite_Site extends WP_UnitTestCase {
$this->assertSame( '', get_blog_option( $blog_id, 'WPLANG' ) );
}
/**
* @ticket 40503
*/
function test_different_network_language() {
$network = get_network( self::$network_ids['make.wordpress.org/'] );
add_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10, 3 );
update_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG', 'wibble' );
$blog_id = wpmu_create_blog( $network->domain, '/de-de/', 'New Blog', get_current_user_id(), array(), $network->id );
remove_filter( 'sanitize_option_WPLANG', array( $this, 'filter_allow_unavailable_languages' ), 10 );
$this->assertSame( get_network_option( self::$network_ids['make.wordpress.org/'], 'WPLANG' ), get_blog_option( $blog_id, 'WPLANG' ) );
}
/**
* Allows to set the WPLANG option to any language.
*