Ticket #29783: 29783.7.diff
| File 29783.7.diff, 1.9 KB (added by , 10 years ago) |
|---|
-
src/wp-includes/l10n.php
28 28 * @return string The locale of the blog or from the {@see 'locale'} hook. 29 29 */ 30 30 function get_locale() { 31 global $locale, $wp_local_package ;31 global $locale, $wp_local_package, $wpdb; 32 32 33 33 if ( isset( $locale ) ) { 34 34 /** … … 50 50 $locale = WPLANG; 51 51 } 52 52 53 // If $wpdb hasn't been initialised yet, we can only return what we have. 54 if ( ! $wpdb ) { 55 if ( ! $locale ) { 56 return 'en_US'; 57 } 58 59 return $locale; 60 } 61 53 62 // If multisite, check options. 54 63 if ( is_multisite() ) { 55 64 // Don't check blog option when installing. -
tests/phpunit/tests/l10n/getLocale.php
81 81 $this->assertSame( 'en_US', $found ); 82 82 } 83 83 84 public function test_should_fall_back_on_locale_when_wpdb_is_unavailable() { 85 global $locale, $wpdb; 86 87 $old_locale = $locale; 88 $old_wpdb = $wpdb; 89 90 $locale = $expected = "Is this a locale? No. No it isn't."; 91 $wpdb = null; 92 93 $found = get_locale(); 94 95 $locale = $old_locale; 96 $wpdb = $old_wpdb; 97 98 $this->assertSame( $expected, $found ); 99 } 100 101 public function test_should_fall_back_on_es_US_when_locale_and_wpdb_are_unavailable() { 102 global $locale, $wpdb; 103 104 $old_locale = $locale; 105 $old_wpdb = $wpdb; 106 107 $locale = null; 108 $wpdb = null; 109 110 $found = get_locale(); 111 112 $locale = $old_locale; 113 $wpdb = $old_wpdb; 114 115 $this->assertSame( 'en_US', $found ); 116 } 117 84 118 public function test_should_respect_get_locale_filter() { 85 119 add_filter( 'locale', array( $this, 'filter_get_locale' ) ); 86 120 $found = get_locale();
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)