ID:               21261
 Updated by:       [EMAIL PROTECTED]
 Reported By:      [EMAIL PROTECTED]
-Status:           Open
+Status:           Closed
 Bug Type:         Scripting Engine problem
 Operating System: linux 2.4.18 - slack 8.1
 PHP Version:      4.3.0
 Assigned To:      shane
 New Comment:

This bug has been fixed in CVS.

In case this was a PHP problem, 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/.
 
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 in short time.
 
Thank you for the report, and for helping us make PHP better.

This is now fixed in cvs:
4.3: http://cvs.php.net/co.php/php4/sapi/cgi/cgi_main.c?r=1.190.2.12
5.0: http://cvs.php.net/co.php/php4/sapi/cgi/cgi_main.c?r=1.208


Previous Comments:
------------------------------------------------------------------------

[2003-01-17 06:36:29] [EMAIL PROTECTED]

Sorry, my PHP-Based Workaround seems to be buggy in some cases, too...
Here is a quick & dirty bugfix for the quick & dirty workaround :-)

Btw, it would be nice if the bug is fixed in PHP 4.3.1...

-snip----------------------------------------
// Small Workaround for a bug in PHP 4.3.0/cgi
// See http://bugs.php.net/bug.php?id=21261 for details

$_SERVER['SCRIPT_NAME'] = substr($_SERVER['PATH_TRANSLATED'],
                                 strlen($_SERVER['DOCUMENT_ROOT']));
if (substr($_SERVER['SCRIPT_NAME'], 0, 2) == '//') {
    $_SERVER['SCRIPT_NAME'] = substr($_SERVER['SCRIPT_NAME'], 1);
}

$PHP_SELF =
$SCRIPT_NAME =
$_SERVER['PHP_SELF'] =
$_SERVER['SCRIPT_NAME'];
-snip------------------------------------

------------------------------------------------------------------------

[2003-01-13 11:41:12] [EMAIL PROTECTED]

That (or similar) urgent problem occurs here too. PHP versions before
mid december were not affected IMO.

At first today I've checked out the "php4" and "php5" modules from CVS,
configured, and build them. After installation of the CGI binaries I
detected a problem with $_SERVER['PHP_SELF']:

a) the PHP4 version shows "no value"
b) the PHP5 version shows illegal characters, cut off strings with low
ASCII values etc. Depending on the namebased vhost name the value of
PHP_SELF looks like "ind##" instead of "index.php" ("#" should
represent low ASCII chars, which are shown as boxes here) of just "5"
which is definitely the last char of "index.php5". Short: looks like a
pointer on a string array is bent somewhere.

The problem insist with and without '--enable-force-cgi-redirect' in
both versions. As an example you may want to take a look at

  http://daniel-gorski.de/index.php4  (PHP4 CGI)
  http://daniel-gorski.de/index.php5  (PHP5 CGI)

and compare the values of $_SERVER['PHP_SELF']. Additionally the PHP5
version has a strange "Zend Extension" date: 90021012. OTOH this value
seems to be correct in the PHP4 version.

The operating system is Linux (RedHat 6.2).

I would appreciate to see this bug solved as soon as possible, because
this is a dramatic show stopper for a few ZE2 applications I am
developing & running.

What required information can I provide to help to solve this problem?

regards dtg

------------------------------------------------------------------------

[2003-01-09 14:57:05] [EMAIL PROTECTED]

Quick & Dirty PHP-Based workaround:

Put this code in a file and add it to auto_prepend_file-directive in
php.ini:
-snip----------------------------------------
// Small Workaround for a bug in PHP 4.3.0/cgi
// See http://bugs.php.net/bug.php?id=21261 for details

$_SERVER['SCRIPT_NAME'] = substr($_SERVER['PATH_TRANSLATED'],
                                 strlen($_SERVER['DOCUMENT_ROOT']));

$PHP_SELF =
$SCRIPT_NAME =
$_SERVER['PHP_SELF'] =
$_SERVER['SCRIPT_NAME'];
-snip------------------------------------

Works fine for me... If PHP is used as CLI it may be neccessary to
check current mode before running this code.

------------------------------------------------------------------------

[2003-01-07 13:30:23] [EMAIL PROTECTED]

There is no space in SCRIPT_NAME on my localhost, this was an
copy&paste-error. But the "I" at the end exists.

------------------------------------------------------------------------

[2003-01-07 13:27:55] [EMAIL PROTECTED]

Same for me, your patch seems to have no affect.

I checked the debugging output from cgiwrap which says:
[...]
Fixing Environment Variables.

Environment Variables:
     QUERY_STRING: ''
      SCRIPT_NAME: '/phpinfo.php'
  SCRIPT_FILENAME: '<DOCUMENT_ROOT>/phpinfo.php'
     REDIRECT_URL: '<NULL>'
        PATH_INFO: '/phpinfo.php'
  PATH_TRANSLATED: '<DOCUMENT_ROOT>/phpinfo.php'
      REMOTE_USER: '<NULL>'
      REMOTE_HOST: '<NULL>'
      REMOTE_ADDR: '217.4.137.70'
[...]

Seems to be ok?! But PHP_SELF has no value.

On my localhost PHP 4.3/CGI works with cgiwrap. The same paragraph with
this machine:
[...]
Fixing Environment Variables. 

Environment Variables: 
     QUERY_STRING: '' 
      SCRIPT_NAME: '/php/ phpinfo.phpI' 
  SCRIPT_FILENAME: '<DOCUMENT_ROOT>/php/phpinfo.php'    
     REDIRECT_URL: '' 
        PATH_INFO: '/php/phpinfo.php' 
  PATH_TRANSLATED: '<DOCUMENT_ROOT>/php/phpinfo.php'     
      REMOTE_USER: '' 
      REMOTE_HOST: '' 
     REMOTE_ADDR: '192.168.23.2'
[...]

In this case, script_name is broken for some reason (don't ask me why,
i didn't find out). But PHP_SELF has the correct value! On both server
SCRIPT_NAME isn't listed in the phpinfo()-Output.

Hope this will help.

------------------------------------------------------------------------

The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
    http://bugs.php.net/21261

-- 
Edit this bug report at http://bugs.php.net/?id=21261&edit=1

Reply via email to