com php-src: Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty: ext/intl/locale/locale _methods.c
ext/intl/tests/locale_bug66289.p hpt

From: Date: Sat, 09 Apr 2016 16:24:42 +0000
Subject: com php-src: Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty: ext/intl/locale/locale _methods.c
ext/intl/tests/locale_bug66289.p hpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-91675@lists.php.net to get a copy of this message
Commit: ef17343b3cb9195437d760ec21dcdf6004a85b67 Author: Anatol Belski <ab@php.net> Sat, 9 Apr 2016 18:22:57 +0200 Parents: c6c44c36298d573932f153071f3bb20007924173 Branches: PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ef17343b3cb9195437d760ec21dcdf6004a85b67 Log: Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty Bugs: https://bugs.php..net/66289 Changed paths: M ext/intl/locale/locale_methods.c A ext/intl/tests/locale_bug66289.phpt Diff: diff --git a/ext/intl/locale/locale_methods.c b/ext/intl/locale/locale_methods.c index c47f283..3471ba4 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 0000000..6afd821 --- /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==

« previous php.cvs (#91675) next »