|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16865 constants and locales not like each other very much..
Submitted: 2002-04-26 19:18 UTC Modified: 2002-07-31 18:50 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: jan at horde dot org Assigned: hholzgra (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.0-dev OS: Linux
Private report: No CVE-ID: None
 [2002-04-26 19:18 UTC] jan at horde dot org
This one is a very strange one. It seems like some constants are getting undefined if you set the locale to tr_TR. It happens randomly with internally defined and user defined constants and is reproducable with this little script:


setlocale(LC_ALL, 'tr_TR');

echo extension_loaded('imap');



Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-28 21:11 UTC]
Not sure whether it happens because tr_TR locale is broken?

When these constants are defined, they are defined using
the current locale whatever it was when PHP starts.

So, it you do this:

# export LC_ALL=tr_TR
# php -f test.php

And it works..
So when constants are searched from the hash, same locale should be used which was used when they were registered.


 [2002-04-29 04:07 UTC] jan at horde dot org
It works indeed if you set the locale before calling the php script. But this is of course not practicable.
 [2002-06-10 12:24 UTC] ilia at prohost dot org
This bug can be resolved by applying the patch below to zend_constants.c

--- zend_constants.c_old        Sat Jun  8 15:58:01 2002
+++ zend_constants.c    Sat Jun  8 15:58:09 2002
@@ -226,8 +226,6 @@
        lookup_name = do_alloca(name_len+1);
        memcpy(lookup_name, name, name_len+1);

-       zend_str_tolower(lookup_name, name_len);
        if (zend_hash_find(EG(zend_constants), lookup_name, name_len+1,
(void **) &c)==SUCCESS) {
                if ((c->flags & CONST_CS) && memcmp(c->name, name,
name_len)!=0) {
@@ -255,7 +253,6 @@
        printf("Registering constant for module %d\n",

-       zend_str_tolower(lowercase_name, c->name_len);
        if (zend_hash_add(EG(zend_constants), lowercase_name,
c->name_len, (void *) c, sizeof(zend_constant), NULL)==FAILURE) {
                if (!(c->flags & CONST_PERSIST
 [2002-07-25 04:37 UTC]
I heard Hartmut is collecting these..

 [2002-07-31 09:13 UTC]
This _seems_ to be fixed in CVS (4.3.0-dev) least I wasn't able to reproduce it anymore.

 [2002-07-31 17:39 UTC] jan at horde dot org
One fixed, one broken. ;-)

The constants seem to work now, but some user defined classes don't exist after setting the locale to tr_TR.

I wasn't able to reproduce this in a short script, but it happens reproduceable in the Horde framework if I try to add a Turkish translation.
 [2002-07-31 18:27 UTC]
you changed the version to 4.2.0? But this is fixed in 4.3.0-dev...did you try with that? :)

 [2002-07-31 18:43 UTC] jan at horde dot org
Ehm, sorry.
 [2002-07-31 18:50 UTC]
Okay, so let's keep this closed for now since the problem is not related to constants anymore.. (how did that topic change suddenly?)

Please check the bugs assigned to Hartmut..most of these locale probs should be assigned to him. If none of those 
match your problem, open a new report with a SHORT testcase
with it.. :) If any of those reports are about this, add your comment there. A short script would be nice to have..

PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 13 07:01:29 2024 UTC