I18N: Fix a PHP fatal when `get_locale()` is called before `$wpdb` is ready.
If WPDB needs to bail early, it loads the translations, which need to load the locale. Without WPDB, we can't get any database options, so can only rely on what's been loaded so far. Fixes #29783. Built from https://develop.svn.wordpress.org/trunk@38976 git-svn-id: http://core.svn.wordpress.org/trunk@38919 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
f2a7e841eb
commit
1c5c130af9
|
@ -28,7 +28,7 @@
|
|||
* @return string The locale of the blog or from the {@see 'locale'} hook.
|
||||
*/
|
||||
function get_locale() {
|
||||
global $locale, $wp_local_package;
|
||||
global $locale, $wp_local_package, $wpdb;
|
||||
|
||||
if ( isset( $locale ) ) {
|
||||
/**
|
||||
|
@ -50,6 +50,15 @@ function get_locale() {
|
|||
$locale = WPLANG;
|
||||
}
|
||||
|
||||
// If $wpdb hasn't been initialised yet, we can only return what we have.
|
||||
if ( ! $wpdb ) {
|
||||
if ( ! $locale ) {
|
||||
return 'en_US';
|
||||
}
|
||||
|
||||
return $locale;
|
||||
}
|
||||
|
||||
// If multisite, check options.
|
||||
if ( is_multisite() ) {
|
||||
// Don't check blog option when installing.
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.7-alpha-38975';
|
||||
$wp_version = '4.7-alpha-38976';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue