-
Notifications
You must be signed in to change notification settings - Fork 3.7k
I18N: Ignore non-string values in the locale getters #13335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
cc1d309
3ec6881
b4cc5f8
4e5a741
c71443c
5d064ff
d6b2ae6
9da8fc8
cae7c02
ce9a317
50ce952
5295341
d72d21d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -46,4 +46,13 @@ public function data_sanitize_locale_name_returns_empty_string() { | |||||
| array( '@///' ), | ||||||
| ); | ||||||
| } | ||||||
|
|
||||||
| /** | ||||||
| * Request parameters can arrive as arrays. | ||||||
| * | ||||||
| * @ticket 66106 | ||||||
| */ | ||||||
| public function test_sanitize_locale_name_returns_empty_string_for_a_non_string() { | ||||||
| $this->assertSame( '', sanitize_locale_name( array( 'de_DE' ) ) ); | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| } | ||||||
| } | ||||||
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -90,4 +90,62 @@ public function test_should_respect_get_locale_filter() { | |||||||||||
| public function filter_get_locale() { | ||||||||||||
| return 'foo'; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Nothing checks the type of the `WPLANG` option on the way out, so a row | ||||||||||||
| * written by a direct database query or a migration reaches the return value. | ||||||||||||
| * | ||||||||||||
| * @ticket 66106 | ||||||||||||
| * | ||||||||||||
| * @group ms-excluded | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The methods could add global docs:
Suggested change
|
||||||||||||
| */ | ||||||||||||
| public function test_should_fall_back_on_en_US_for_a_non_string_option(): void { | ||||||||||||
| global $locale, $wpdb; | ||||||||||||
| $old_locale = $locale; | ||||||||||||
| $locale = null; | ||||||||||||
|
Comment on lines
+104
to
+105
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be done in |
||||||||||||
|
|
||||||||||||
| $wpdb->replace( | ||||||||||||
| $wpdb->options, | ||||||||||||
| array( | ||||||||||||
| 'option_name' => 'WPLANG', | ||||||||||||
| 'option_value' => maybe_serialize( array( 'de_DE' ) ), | ||||||||||||
| ) | ||||||||||||
| ); | ||||||||||||
| wp_cache_flush(); | ||||||||||||
|
|
||||||||||||
| $found = get_locale(); | ||||||||||||
| $locale = $old_locale; | ||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be done in |
||||||||||||
|
|
||||||||||||
| $this->assertSame( 'en_US', $found ); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @ticket 66106 | ||||||||||||
| */ | ||||||||||||
| public function test_should_fall_back_on_en_US_for_a_non_string_locale_global(): void { | ||||||||||||
| global $locale; | ||||||||||||
| $old_locale = $locale; | ||||||||||||
| $locale = array( 'de_DE' ); | ||||||||||||
|
|
||||||||||||
| $found = get_locale(); | ||||||||||||
| $locale = $old_locale; | ||||||||||||
|
|
||||||||||||
| $this->assertSame( 'en_US', $found ); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * @ticket 66106 | ||||||||||||
| */ | ||||||||||||
| public function test_should_ignore_a_non_string_locale_filter(): void { | ||||||||||||
| global $locale; | ||||||||||||
| $old_locale = $locale; | ||||||||||||
| $locale = 'es_ES'; | ||||||||||||
|
|
||||||||||||
| add_filter( 'locale', '__return_empty_array' ); | ||||||||||||
|
|
||||||||||||
| $found = get_locale(); | ||||||||||||
| $locale = $old_locale; | ||||||||||||
|
|
||||||||||||
| $this->assertSame( 'es_ES', $found ); | ||||||||||||
| } | ||||||||||||
| } | ||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since the other test methods have
void: