php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #12264 PATH_INFO and PATH_TRANSLATED not being correctly set
Submitted: 2001-07-19 14:29 UTC Modified: 2002-12-03 01:37 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: jah at fountainheadent dot com Assigned:
Status: Closed Package: IIS related
PHP Version: 4.0.6 OS: Win2K Server
Private report: No CVE-ID: None
 [2001-07-19 14:29 UTC] jah at fountainheadent dot com
Hello,

The scripts that we are running use PATH_INFO to determine where a user is trying to access, and this became a problem when we switched over from using Apache to using IIS. Once we made the switch from Apache to IIS we were getting continual CGI Errors (like virtually every single hit was a CGI Error) [ and this was not because of permissions ]

As it turns out, the only pages where we would not get a CGI error was the root page, which had an empty PATH_INFO. Here's an example:

Our root script is /test.php. If I requested /test.php everything would work fine; However if I requested /test.php/hello/world I
would get a CGI Error (under IIS). Under Apache I would get the proper results -- it would run /test.php and PATH_INFO would be 
/hello/world.

But anyways - after spending some time poking around the PHP source I found that PHP was trying to execute the wrong file! In the above example, it was attempting to run /test.php/hello/world instead of /test.php (SCRIPT_NAME was being to /test.php). To me it looked like IIS was setting PATH_INFO and PATH_TRANSLATED differently than PHP was expecting, so I made a change the the source so that it would modify those two until they were in working order. I'm not sure if my change is correct - but it did fix the problem).

(Note: The problem is independent of the actual script - any script where you put stuff on the URL in this manner will have this problem)

=====

What follows now is the output that I had PHP give on what it was trying to run. The first is the original version that didn't work, followed by the version with the changes that I made, and the proper results:

In both of the cases, the requested URL was:

http://192.168.1.2/test.php/hello/world


Original (non-working) version
------------------------------
PHP Output follows

SG(request_info).path_translated: (null)
PATH_INFO      : /test.php/hello/world
SCRIPT_NAME    : /test.php
SG(request_info).request_uri = /test.php/hello/world
php_fopen_primary_script(): filename  = C:\web\fcsweb\test.php\hello\world
php_fopen_primary_script(): path_info = /test.php/hello/world

=====

So you can see that in the original request it is trying to run the wrong script. With the changes I made, I now get the following:

New (working) version
---------------------
PHP Output follows

SG(request_info).path_translated: C:\web\fcsweb\test.php
PATH_INFO      : /hello/world
SCRIPT_NAME    : /test.php
SG(request_info).request_uri = /hello/world
php_fopen_primary_script(): filename  = C:\web\fcsweb\test.php
php_fopen_primary_script(): path_info = /hello/world

=====

Some more information on our system:

OS: Win2k Server SP1
Webserver: IIS4
PHP: 4.0.6 CGI mode

And finally, the patch for the changes I made to cgi_main.c are at:

http://div.dyndns.org/jah/php/iis_cgi_path_fix.patch

I've never submitted a patch before, so I don't know if it's done in the right manner...

Hopefully I've analyzed this whole issue somewhat correctly... :)

Thanks!

-Jah

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-07-20 03:20 UTC] jah at fountainheadent dot com
Hmm, looks like my patch thing didn't quite work [for one, PATH_INFO isn't being set right, then I think there are also some memory leaks]) ... I had an old very hacky patch around here that I ended up reverting to for now.

A proper fix for this problem would be great :)
 [2002-06-03 12:12 UTC] mfischer@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately your version of PHP is too old -- the problem
might already be fixed. Please download a new PHP
version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.


 [2002-12-03 01:37 UTC] shane@php.net
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.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 11:01:28 2024 UTC