Bug #69481 [NEW]: how php initializes locale is not documented

From: Date: Sun, 19 Apr 2015 08:11:54 +0000
Subject: Bug #69481 [NEW]: how php initializes locale is not documented
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-192201@lists.php.net to get a copy of this message
From: glen at delfi dot ee Operating system: PHP version: Irrelevant Package: *General Issues Bug Type: Bug Bug description:how php initializes locale is not documented Description: ------------ seems php initializes ONLY LC_CTYPE from enviroment, leaving default behaviour that declaring LC_ALL value overrides any other category BROKEN: this seems to be related to some experiment done in 2000 and then reverted: https://github.com/php/php-src/commit/7e0baa7a1daa531e39881e59842c88d12e42c901 the fact that there even is setlocale(LC_CTYPE, "") done unconditionally in php init, is not documented. but i think it should be either: 1. no unconditional setlocale() call at all 2. setlocale(LC_ALL, ""); 3. setlocale(LC_ALL, "C"); the last one is probably the worst. Test script: --------------- compare how system date command behaves and how php behaves: test1: only LC_ALL env var is set, but php resets LC_CTYPE, meaning LC_CTYPE gets env value, the other categories get reset to C: $ env -i LC_ALL=et_EE.utf8 php -r 'var_dump(setlocale(LC_ALL, 0)); passthru("set -x;env;date +%A%d.%B"); echo "\nPHP:", strftime("%A, %d. %B"), "\n";' string(169) "LC_CTYPE=et_EE.utf8;LC_NUMERIC=C;LC_TIME=C;LC_COLLATE=C;LC_MONETARY=C;LC_MESSAGES=C;LC_PAPER=C;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=C;LC_IDENTIFICATION=C" + env _=/usr/bin/env LC_ALL=et_EE.utf8 PATH=/usr/bin:/bin + date +%A%d.%B pühapäev19.aprill PHP:Sunday, 19. April test2: if php would do setlocale(LC_ALL, "") instead of setlocale(LC_CTYPE, ""), then result is as expeted, LC_ALL overrides all categories. shell and php behaviour matches: $ env -i LC_ALL=et_EE.utf8 php -r 'setlocale(LC_ALL, ""); var_dump(setlocale(LC_ALL, 0)); passthru("set -x;env;date +%A%d.%B"); echo "\nPHP:", strftime("%A, %d. %B"), "\n";' string(10) "et_EE.utf8" + env _=/usr/bin/env LC_ALL=et_EE.utf8 PATH=/usr/bin:/bin + date +%A%d.%B pühapäev19.aprill PHP:pühapäev, 19. aprill -- Edit bug report at https://bugs.php.net/bug.php?id=69481&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69481&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69481&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69481&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=69481&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=69481&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=69481&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=69481&r=needscript Try newer version: https://bugs.php.net/fix.php?id=69481&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=69481&r=support Expected behavior: https://bugs.php.net/fix.php?id=69481&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=69481&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=69481&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=69481&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69481&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=69481&r=dst IIS Stability: https://bugs.php.net/fix.php?id=69481&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=69481&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=69481&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=69481&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=69481&r=mysqlcfg

« previous php.bugs (#192201) next »