mirror of
https://github.com/php/php-src.git
synced 2026-03-26 01:02:25 +01:00
Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
This commit is contained in:
@@ -1548,7 +1548,11 @@ PHP_FUNCTION(locale_lookup)
|
||||
}
|
||||
|
||||
if(loc_range_len == 0) {
|
||||
loc_range = intl_locale_get_default();
|
||||
if(fallback_loc_str) {
|
||||
loc_range = ZSTR_VAL(fallback_loc_str);
|
||||
} else {
|
||||
loc_range = intl_locale_get_default();
|
||||
}
|
||||
}
|
||||
|
||||
hash_arr = Z_ARRVAL_P(arr);
|
||||
|
||||
27
ext/intl/tests/locale_bug66289.phpt
Normal file
27
ext/intl/tests/locale_bug66289.phpt
Normal file
@@ -0,0 +1,27 @@
|
||||
--TEST--
|
||||
Bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
|
||||
--SKIPIF--
|
||||
<?php if( !extension_loaded( 'intl' ) ) print 'skip'; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
ini_set("intl.default_locale", "en-US");
|
||||
$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419', 'en_US');
|
||||
var_dump(locale_lookup($availableLocales, false, true, 'fr_FR'));
|
||||
var_dump(locale_lookup($availableLocales, false, true, null));
|
||||
|
||||
$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419');
|
||||
var_dump(locale_lookup($availableLocales, false, true, 'fr_FR'));
|
||||
|
||||
ini_set("intl.default_locale", "de-DE");
|
||||
$availableLocales = array(Locale::getDefault());
|
||||
var_dump(locale_lookup($availableLocales, false, true));
|
||||
|
||||
?>
|
||||
==DONE==
|
||||
--EXPECT--
|
||||
string(5) "fr_fr"
|
||||
string(5) "en_us"
|
||||
string(5) "fr_fr"
|
||||
string(5) "de_de"
|
||||
==DONE==
|
||||
Reference in New Issue
Block a user