Changeset 57286
- Timestamp:
- 01/15/2024 06:55:59 PM (8 months ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/install.php
r57239 r57286 330 330 $language = ''; 331 331 if ( ! empty( $_REQUEST['language'] ) ) { 332 $language = preg_replace( '/[^a-zA-Z0-9_]/', '',$_REQUEST['language'] );332 $language = sanitize_locale_name( $_REQUEST['language'] ); 333 333 } elseif ( isset( $GLOBALS['wp_local_package'] ) ) { 334 334 $language = $GLOBALS['wp_local_package']; -
trunk/src/wp-includes/l10n.php
r57233 r57286 151 151 ) { 152 152 $determined_locale = get_user_locale(); 153 } elseif ( 154 ( ! empty( $_REQUEST['language'] ) || isset( $GLOBALS['wp_local_package'] ) ) 155 && wp_installing() 156 ) { 157 if ( ! empty( $_REQUEST['language'] ) ) { 158 $determined_locale = sanitize_locale_name( $_REQUEST['language'] ); 159 } else { 160 $determined_locale = $GLOBALS['wp_local_package']; 161 } 153 162 } 154 163 -
trunk/tests/phpunit/tests/l10n/determineLocale.php
r56559 r57286 21 21 22 22 public function tear_down() { 23 unset( $_SERVER['CONTENT_TYPE'], $_GET['_locale'], $_COOKIE['wp_lang'], $GLOBALS['pagenow'] ); 23 unset( 24 $_SERVER['CONTENT_TYPE'], 25 $_GET['_locale'], 26 $_COOKIE['wp_lang'], 27 $GLOBALS['pagenow'], 28 $GLOBALS['wp_local_package'], 29 $_REQUEST['language'] 30 ); 31 wp_installing( false ); 24 32 25 33 parent::tear_down(); … … 274 282 $this->assertSame( 'siteLocale', determine_locale() ); 275 283 } 284 285 public function test_language_param_not_installing() { 286 $_REQUEST['language'] = 'de_DE'; 287 $this->assertSame( 'en_US', determine_locale() ); 288 } 289 290 public function test_language_param_installing() { 291 $_REQUEST['language'] = 'de_DE'; 292 wp_installing( true ); 293 $this->assertSame( 'de_DE', determine_locale() ); 294 } 295 296 public function test_language_param_installing_incorrect_string() { 297 $_REQUEST['language'] = '####'; // Something sanitize_locale_name() strips away. 298 wp_installing( true ); 299 $this->assertSame( 'en_US', determine_locale() ); 300 } 301 302 public function test_wp_local_package_global_not_installing() { 303 $_REQUEST['language'] = 'de_DE'; 304 $this->assertSame( 'en_US', determine_locale() ); 305 } 306 public function test_wp_local_package_global_installing() { 307 $_REQUEST['language'] = 'de_DE'; 308 wp_installing( true ); 309 $this->assertSame( 'de_DE', determine_locale() ); 310 } 276 311 }
Note: See TracChangeset
for help on using the changeset viewer.