Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/wp-admin/includes/schema.php
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,11 @@ function populate_options( array $options = array() ) {
$defaults['permalink_structure'] = '/%year%/%monthnum%/%day%/%postname%/';
}

// 7.3.0
if ( ! is_multisite() && ( ! defined( 'WPLANG' ) || '' === WPLANG ) ) {
$defaults['WPLANG'] = '';
}

$options = wp_parse_args( $options, $defaults );

// Set autoload to no for these options.
Expand Down Expand Up @@ -1138,6 +1143,11 @@ function populate_network( $network_id = 1, $domain = '', $email = '', $site_nam
update_user_meta( $site_user_id, 'source_domain', $domain );
update_user_meta( $site_user_id, 'primary_blog', $current_site->blog_id );

// Let the main site fall back to the network language instead of an empty site language.
if ( '' === get_option( 'WPLANG' ) ) {
delete_option( 'WPLANG' );
}

// Unable to use update_network_option() while populating the network.
$wpdb->insert(
$wpdb->sitemeta,
Expand Down
85 changes: 85 additions & 0 deletions tests/phpunit/tests/admin/includesSchema.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,91 @@ public function test_populate_options_when_locale_uses_deprecated_timezone_strin
$this->assertSame( 'America/Buenos_Aires', $result );
}

/**
* @ticket 50980
* @group ms-excluded
*/
public function test_populate_options_adds_autoloaded_empty_wplang_on_single_site() {
global $wpdb;

$orig_options = $wpdb->options;
$wpdb->options = self::$options;

populate_options();

wp_cache_delete( 'alloptions', 'options' );
wp_cache_delete( 'notoptions', 'options' );
wp_load_alloptions();

$num_queries = get_num_queries();
$result = get_option( 'WPLANG' );
$queries = get_num_queries() - $num_queries;

$wpdb->query( "TRUNCATE TABLE {$wpdb->options}" );
$wpdb->options = $orig_options;
wp_cache_delete( 'alloptions', 'options' );
wp_cache_delete( 'notoptions', 'options' );

$this->assertSame( '', $result, 'WPLANG should default to an empty string.' );
$this->assertSame( 0, $queries, 'WPLANG should be autoloaded.' );
}

/**
* @ticket 50980
* @group ms-excluded
*/
public function test_populate_options_keeps_existing_wplang() {
global $wpdb;

$orig_options = $wpdb->options;
$wpdb->options = self::$options;

$wpdb->insert(
$wpdb->options,
array(
'option_name' => 'WPLANG',
'option_value' => 'de_DE',
)
);

populate_options();

wp_cache_delete( 'alloptions', 'options' );
wp_cache_delete( 'notoptions', 'options' );

$result = get_option( 'WPLANG' );

$wpdb->query( "TRUNCATE TABLE {$wpdb->options}" );
$wpdb->options = $orig_options;
wp_cache_delete( 'alloptions', 'options' );
wp_cache_delete( 'notoptions', 'options' );

$this->assertSame( 'de_DE', $result );
}

/**
* @ticket 50980
* @group multisite
* @group ms-required
*/
public function test_populate_options_does_not_add_wplang_on_multisite() {
global $wpdb;

$orig_options = $wpdb->options;
$wpdb->options = self::$options;

populate_options();

$result = $wpdb->get_var( $wpdb->prepare( "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s", 'WPLANG' ) );

$wpdb->query( "TRUNCATE TABLE {$wpdb->options}" );
$wpdb->options = $orig_options;
wp_cache_delete( 'alloptions', 'options' );
wp_cache_delete( 'notoptions', 'options' );

$this->assertNull( $result );
}

/**
* @ticket 44896
* @group multisite
Expand Down
2 changes: 1 addition & 1 deletion tests/qunit/fixtures/wp-api-generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -15021,7 +15021,7 @@ mockedApiResponse.settings = {
"date_format": "F j, Y",
"time_format": "g:i a",
"start_of_week": 1,
"language": "en_US",
"language": "",
"use_smilies": true,
"default_category": 1,
"default_post_format": "0",
Expand Down
Loading