php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55173 Locale::setDefault never failed
Submitted: 2011-07-11 05:03 UTC Modified: 2018-09-21 05:46 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: jinmoku at hotmail dot com Assigned: carusogabriel (profile)
Status: Assigned Package: I18N and L10N related
PHP Version: Next major version OS: *
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2011-07-11 05:03 UTC] jinmoku at hotmail dot com
Description:
------------
Locale::setDefault never failed even with wrong value

Test script:
---------------
var_dump(Locale::setDefault(''));
var_dump(Locale::setDefault(null));
var_dump(Locale::setDefault(false));
var_dump(Locale::setDefault(true));
var_dump(Locale::setDefault('en_US'));

Expected result:
----------------
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)

Actual result:
--------------
bool(true)
bool(true)
bool(true)
bool(true)
bool(true)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-07-11 05:49 UTC] jinmoku at hotmail dot com
you don't use uloc_setDefault  ???
 [2015-06-24 21:17 UTC] cmb@php.net
-Status: Open +Status: Verified -Operating System: Win 7 +Operating System: * -PHP Version: 5.3.6 +PHP Version: 5.6.10
 [2015-06-24 21:17 UTC] cmb@php.net
Basically, Locale::setDefault($string) behaves the same as
ini_set('intl.default_locale', $string)[1].

It is arguable whether this is a bug, but at least the
documentation regarding the return value should be improved.

[1] <http://3v4l.org/A3ooa>
 [2018-08-11 18:46 UTC] carusogabriel@php.net
`Locale::setDefault` has always true return: http://git.php.net/?p=php-src.git;a=blob;f=ext/intl/locale/locale_methods.c;hb=HEAD#l248

Might be interesting drop this and make it void in the next PHP version, as it's considered a BC.
 [2018-09-21 05:46 UTC] carusogabriel@php.net
-PHP Version: 5.6.10 +PHP Version: Next major version -Assigned To: +Assigned To: carusogabriel
 [2018-09-21 05:46 UTC] carusogabriel@php.net
-Status: Verified +Status: Assigned
 
PHP Copyright © 2001-2018 The PHP Group
All rights reserved.
Last updated: Fri Sep 21 07:01:25 2018 UTC