diff options
author | Anatol Belski <ab@php.net> | 2016-04-09 18:27:57 +0200 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2016-04-09 18:27:57 +0200 |
commit | 55405259695da634aeab341063c8dc91bc54bc4d (patch) | |
tree | d2d68c4e318f76197f19b5c4d3f25cc9eba96a3b | |
parent | bffd78fa771a7d424a84a54bc2926aa999f685de (diff) | |
parent | ef17343b3cb9195437d760ec21dcdf6004a85b67 (diff) | |
download | php-git-55405259695da634aeab341063c8dc91bc54bc4d.tar.gz |
Merge branch 'PHP-7.0'
* PHP-7.0:
Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
-rw-r--r-- | ext/intl/locale/locale_methods.c | 6 | ||||
-rw-r--r-- | ext/intl/tests/locale_bug66289.phpt | 27 |
2 files changed, 32 insertions, 1 deletions
diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index c47f283201..3471ba4053 100644 --- a/ext/intl/locale/locale_methods.c +++ b/ext/intl/locale/locale_methods.c @@ -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); diff --git a/ext/intl/tests/locale_bug66289.phpt b/ext/intl/tests/locale_bug66289.phpt new file mode 100644 index 0000000000..6afd821b5a --- /dev/null +++ b/ext/intl/tests/locale_bug66289.phpt @@ -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== |