php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #39993 tr_TR.UTF-8 locale has problems with PHP
Submitted: 2006-12-30 18:22 UTC Modified: 2007-01-18 23:20 UTC
From: tunix at raptiye dot org Assigned: derick
Status: Closed Package: Date/time related
PHP Version: 5.2.0 OS: Arch Linux
Private report: No CVE-ID:
 [2006-12-30 18:22 UTC] tunix at raptiye dot org

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-12-30 20:46 UTC] derick@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php5.2-win32-latest.zip
 [2006-12-30 23:08 UTC] tony2001@php.net
Its is reproducible with the snapshot.
I believe this happens because of strcasecmp() (used in seek_to_tz_position()) behaving weird with tr_TR locale (I remember some similar problems in the past), using something like tolower() & memcmp() should do the trick.
 [2006-12-30 23:45 UTC] iliaa@php.net
Another option that is a bit more performance friendly is 
something like this:

http://bb.prohost.org/patch/date.txt
 [2007-01-01 13:38 UTC] tokul at users dot sourceforge dot net
Issue is not fixed in 5.2.x snapshots (200701011130). You are using locale dependent case insensitive lookups and assume locale independent case sensitivity rules. In Turkish locale 'latin small i' is not same thing as 'latin capital i'. Turks have different case sensitivity rules.

Reproduce code
(TZ='Europe/Helsinki' /usr/bin/php /path/test-locale.php):
---
<?php
var_dump(setlocale(LC_ALL,'tr_TR.UTF-8'));
var_dump(date_default_timezone_get());
var_dump(setlocale(LC_CTYPE,0));
---

Expected result:
---
string(11) "tr_TR.UTF-8"
string(15) "Europe/Helsinki"
string(11) "tr_TR.UTF-8"
---
Second line depends on default timezone setting. Make sure that you have 'i' symbol in timezone name.

Actual result (PHP 5.2.0-8 debian and PHP 5.2.1RC2-dev snapshot):
---
string(11) "tr_TR.UTF-8"

Fatal error: date_default_timezone_get(): Timezone database is corrupt - this should *never* happen! in /path/test-locale.php on line 3
---

Patch by iliaa@php.net is not correct, because it does not preserve existing LC_CTYPE value and makes all strtolower/strtoupper calls locale independent when PHP manual states that these calls are locale dependent.

Result after Iliaa's patch is applied:
---
string(11) "tr_TR.UTF-8"
string(15) "Europe/Helsinki"
string(1) "C"
---
 [2007-01-18 23:20 UTC] iliaa@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Thu Apr 24 21:01:55 2014 UTC