1
0
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:
Anatol Belski
2016-04-09 18:22:57 +02:00
parent c6c44c3629
commit ef17343b3c
2 changed files with 32 additions and 1 deletions

View File

@@ -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);

View 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==