php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17642 setting certain locales undefines defines
Submitted: 2002-06-07 11:00 UTC Modified: 2002-06-07 13:31 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: ilia at prohost dot org Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 4.2.1 OS: Linux 2.4.18
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ilia at prohost dot org
New email:
PHP Version: OS:

 

 [2002-06-07 11:00 UTC] ilia at prohost dot org
Setting certain locales, such as tr_TR (Turkish) undefines certain defines. Here is an example script
<?
define('__REQUEST_TIMESTAMP__', time());
echo "BEFORE: ".__REQUEST_TIMESTAMP__."<br>\n";
setlocale(LC_ALL, 'tr_TR');
echo "AFTER: ".__REQUEST_TIMESTAMP__."<br>\n";
?>
Results in the following output:

BEFORE: 1023461965

Notice: Use of undefined constant __REQUEST_TIMESTAMP__ - assumed '__REQUEST_TIMESTAMP__' in /home/forum/test.php on line 12
AFTER: __REQUEST_TIMESTAMP__

On the otherhand using any other locale, such as de_DE or pl_PL seems to work fine and does not undefine the define.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-07 11:03 UTC] ilia at prohost dot org
One more thing, If i use the get_defined_constants() function to fetch the list of all the defines, the __REQUEST_TIMESTAMP__ is always there and always has the correct value in it.
 [2002-06-07 11:14 UTC] derick@php.net
This is because the 'I' doesn't exist in tr_TR.

Derick
 [2002-06-07 11:28 UTC] ilia at prohost dot org
Yeah, that does appear to be the problem, any define containing the letter 'I' gets broken after the local is exported.
Interestingly enough, if I move the define below the setlocale() lin,e it begins to work fine. Also, this does not seem to be a problem for variable names as they are unaffected by change in locale.
 [2002-06-07 11:47 UTC] ilia at prohost dot org
I've looked the Zend constants code and it appears the code ALWAYS lowercases the name of the define (not done for variables). To lowercase the define name, C's tolower() function is used, which obides by locale settings, since I is not avaliable it is left as is accoring to the tolower()'s man page.

The solution which appears to work, seems to be the removal of
zend_str_tolower(lookup_name, name_len);
inside ZEND_API int zend_get_constant function and removal of 
end_str_tolower(lowercase_name, c->name_len);
inside ZEND_API int zend_register_constant
 [2002-06-07 13:31 UTC] sniper@php.net
Please don't open new bug reports about exactly same issues,
especially when you don't have any new information / patches
for it..

http://bugs.php.net/bug.php?id=16865&edit=1

 [2002-11-19 05:04 UTC] eodabas at progen dot com dot tr
just an information, there is an "I" letter in turkish, but the lowercase of "I" is not "i" :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 11:01:33 2024 UTC