php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #21771 variable names changing in turkish locale
Submitted: 2003-01-20 06:24 UTC Modified: 2003-01-30 13:37 UTC
From: tufan at metu dot edu Assigned:
Status: Not a bug Package: Variables related
PHP Version: 4.3.0 OS: linux kernel 2.4.18
Private report: No CVE-ID: None
 [2003-01-20 06:24 UTC] tufan at metu dot edu
I thought this bug was submitted for an earlier version of php (maybe 4.1.2 or so), but it seems to be not corrected.

The main problem is, the lowercase of "I" in Turkish is not "i". it is an "i" without a dot on top of it: "?".

Something in php affects all variables including the letter "I". So $_SESSION, SID, or PHPSESSID doesn't work.

I think some code in php first changes all variables names to lowercase (and for turkish locale, incorrectly lowercases I to i), and then changes all variable names to uppercase (and correctly uppercases i to ?).

So, $_SESSION becomes $_SESS?ON, and since php couldn't find a variable named $_SESSION, it regenerates a new PHPSESSID.

The correct uppercase - lowercase of this letter is:

I - ?
? - i

A workaround for this is making sure apache server starts in en_US locale.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-01-20 06:39 UTC] tufan at metu dot edu
Oops... This may not be related to php. It may be resulting from the turkish locale system itself. Let me investigate...
 [2003-01-20 16:03 UTC] sniper@php.net
Can you provide some short example script?
And what locale causes this?

 [2003-01-21 06:24 UTC] tufan at metu dot edu
no code works. even the example in the php session documentation...
:)

<?php
session_start();
// Use $HTTP_SESSION_VARS with PHP 4.0.6 or less
if (!isset($_SESSION['count'])) {
    $_SESSION['count'] = 0;
} else {
    $_SESSION['count']++;
}
echo "Count {$_SESSION['count']}";
?>
 [2003-01-21 06:27 UTC] tufan at metu dot edu
by the way, it's turkish locale
tr_TR
iso8859-9
 [2003-01-21 11:26 UTC] hholzgra@php.net
strange ... this was fixed for functions constants
but should not affect variables, as these are 
case insensitive (so no conversions take place
while resolving them)
or is there something different going on with
the super-globals?

does this affect $_SESSION only? what if you have
register_globals enabled and try to pass something
like "...script.php?ID=test"? do you have $ID or
$?D set in your script then?
 [2003-01-21 19:10 UTC] sniper@php.net
restore mangled summary and OS entries.

 [2003-01-28 23:19 UTC] sniper@php.net
And are the names mangled in $GLOBALS too?
try:

<?php var_dump($GLOBALS); ?>

And check the output for the _COOKIE / _SESSION indexes.

 [2003-01-29 12:21 UTC] michael dot mauch at gmx dot de
Tufan, can you please (after answering Sniper's questions) try and put the following lines into your apachectl:

unset LC_ALL
LC_CTYPE=C
export LC_CTYPE

See my comments on http://bugs.php.net/bug.php?id=21919 (in short: perhaps this is Apache's problem, because it happens also with mod_perl).
 [2003-01-30 03:30 UTC] tufan at metu dot edu
Hmm...
Indeed, this seems to be a apache problem.

I took a look at the locale definition files for my OS (RedHat 7.2) and they seem to contain correct definitions of uppercase and lowercase letters (and their correspondance).

when

register_globals=on
LC_CTYPE=tr_TR

script.php?ID=some_value works perfectly.

with the same settings, a var_dump($GLOBALS) gives:

  ["HTTP_ACCEPT_ENCOD?NG"]=>
  string(38) "deflate, gzip, x-gzip, identity, *;q=0"
  ["HTTP_CONNECT?ON"]=>
  string(14) "Keep-Alive, TE"
  ["HTTP_COOK?E"]=>
  string(42) "PHPSESSID=4035cdd7974d97ccdcd79f9f711299c1"
  ["HTTP_COOK?E2"]=>
  string(10) "$Version=1"

Note the ? in the variable names. However, names of variables such as SCRIPT_FILENAME, SERVER_ADMIN, or SERVER_SIGNATURE are correct, i.e. they contain an I and not an ?.

In fact, as much as I can see, variables with this problem are only those containing "COOKIE", "ENCODING", and "CONNECTION" words (whether they are global or indices in the _SERVER or HTTP_SERVER_VARS). The other variables containing "I" are correct.

So my original problem was actually: Since the register_globals off and since apache did not pass cookies due to the incorrect variable name (when it started with LC_CTYPE=tr_TR), my session script didn't work.

The same (or similar) problem occurs with mod_mime_magic.so, when enabled, apache does not start at all, giving the error message "Invalid command 'MIMEMagicFile', perhaps mis-spelled or...".

So,

unset LC_ALL
LC_CTYPE=C    (or LC_CTYPE=en_US)
export LC_CTYPE

works (but you should do apachectl stop and apachectl start, instead of apachectl restart).

Since this is probably a problem at the server side itself, a setlocale(LC_ALL,"en_US") in the php script itself does not work (a friend of mine had recommended trying, I gave a shot).

Thank you all for your help.
 [2003-01-30 11:00 UTC] michael dot mauch at gmx dot de
Thanks for checking it out. Can you please close or "bogusify" the bug, then (I can't, since I'm neither the submitter nor a PHP developer)?

As a last note: probably you will need to use something like

  setlocale(LC_CTYPE,"tr_TR") 

if you use strtoupper("i") etc., because otherwise PHP cannot know that you want to get an uppercase I with dot.
 [2003-01-30 13:37 UTC] sniper@php.net
let's close this then. You should propably report this to
the nice apache folks?

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 10:01:31 2024 UTC