php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
Submitted: 2013-12-13 16:12 UTC Modified: 2014-12-24 17:06 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: mark at moderndeveloperllc dot com Assigned:
Status: Closed Package: intl (PECL)
PHP Version: 5.5.7 OS: OSX 10.9
Private report: No CVE-ID: None
 [2013-12-13 16:12 UTC] mark at moderndeveloperllc dot com
Description:
------------
If either en_US or en are included in the $langtag parameter array, and the locale is empty(), then the en_US or en is returned - regardless of the set default. If neither are in $langtag, then the function acts as expected.

This is similar to Bug #60166, but is different in that having a specific locale in the $langtag changes the behavior from unexpected to buggy.

Test script:
---------------
<?php

$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419', 'en_US');
echo locale_lookup($availableLocales, false, true, 'fr_FR');
echo locale_lookup($availableLocales, false, true, null);


$availableLocales = array('fr_FR', 'de', 'es_ES', 'es_419');
echo locale_lookup($availableLocales, false, true, 'fr_FR');


Expected result:
----------------
fr_FR
null
fr_FR

Actual result:
--------------
en_us
en_us
fr_FR

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-06-11 21:19 UTC] mark at moderndeveloperllc dot com
Still existent in 5.5.13.
 [2014-12-24 17:06 UTC] mark at moderndeveloperllc dot com
Still happening in 5.6.4. intl 1.1.0; ICU 54.1
 [2016-04-09 16:28 UTC] ab@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ef17343b3cb9195437d760ec21dcdf6004a85b67
Log: Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
 [2016-04-09 16:28 UTC] ab@php.net
-Status: Open +Status: Closed
 [2016-07-20 11:32 UTC] davey@php.net
Automatic comment on behalf of ab
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ef17343b3cb9195437d760ec21dcdf6004a85b67
Log: Fixed bug #66289 Locale::lookup incorrectly returns en or en_US if locale is empty
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 11:01:29 2024 UTC