php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17658 defines do not work properly
Submitted: 2002-06-08 15:42 UTC Modified: 2002-07-31 09:11 UTC
Votes:3
Avg. Score:3.7 ± 1.9
Reproduced:1 of 3 (33.3%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: ilia at prohost dot org Assigned: hholzgra (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0CVS-2002-06-08 OS: Linux 2.4.18
Private report: No CVE-ID: None
 [2002-06-08 15:42 UTC] ilia at prohost dot org
<?php

        define('TEST', 'test#1');
        define('test', 'test#2');

        echo TEST."\n";
        echo test."\n";
?>

Returns

test#1
test

The problem is the fault of zend_constants, which ALWAYS lowercases the define names when they are being stores/retrieved in/from the hash table. The same lowercasing code also causes i18n problems, with defines which do not support the characters in defines made prior to setlocale() function being called. Ref Bug #16865.

The patch below fixes both problems

--- 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) {
                        retval=0;
@@ -255,7 +253,6 @@
        printf("Registering constant for module %d\n", c->module_number);
 #endif

-       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) {
                free(c->name);
                if (!(c->flags & CONST_PERSISTENT)

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-06-17 09:05 UTC] hholzgra@php.net
i'm working on the locale dependencies issues
within the Zend engine, switching to non-locale
dependant implementations of tolower() and strtod()
 [2002-07-31 09:11 UTC] iliaa@php.net
This bug has been fixed in CVS. You can grab a snapshot of the
CVS version at http://snaps.php.net/. In case this was a documentation 
problem, the fix will show up soon at http://www.php.net/manual/.
In case this was a PHP.net website problem, the change will show
up on the PHP.net site and on the mirror sites.
Thank you for the report, and for helping us make PHP better.

Appears to work fine in 4.3.0
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 07 19:01:28 2024 UTC