|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #34554 $_SERVER['PATH_INFO'] always empty when PHP invoked from CGI script
Submitted: 2005-09-19 23:00 UTC Modified: 2005-09-20 11:13 UTC
From: jr-php2 at quo dot to Assigned:
Status: Not a bug Package: CGI/CLI related
PHP Version: 5.0.5 OS: Linux
Private report: No CVE-ID: None
 [2005-09-19 23:00 UTC] jr-php2 at quo dot to
Under PHP 5, when PHP is invoked from a CGI script (using Apache 2.0.54's standard mod_cgi mechanism), the PATH_INFO environment variable is always empty.

I've found that this problem is related to the "cgi.fix_pathinfo" option. When this option is set to 1 -- the default in PHP 5.0.5 -- PATH_INFO is always empty. When this option is set to 0 -- the default in PHP 4.4.0 -- PATH_INFO is set correctly.

This same(?) issue was reported in Bug #23800, but apparently the reporter was content with just setting cgi.fix_pathinfo=0 and closing the report. The actual problem with PATH_INFO being empty when cgi.fix_pathinfo=1 went unaddressed.

I do not see any reason to believe this behavior is correct. The (rather vague) documentation for cgi.fix_pathinfo states:

"...For more information on PATH_INFO, see the cgi specs. Setting this to 1 will cause PHP CGI to fix it's paths to conform to the spec."

The CGI specs certainly don't say that PATH_INFO should be an empty string, so we aren't seeing increased conformance with the spec here. On the contrary, setting PATH_INFO to an empty string when there is path info introduces non-conformance with the spec.

My PHP configure line:
./configure --prefix=/usr/local/php-cgi --enable-track-vars --with-mysql --with-zlib --with-openssl --enable-discard-path

Reproduce code:
Create a file named "test.cgi" with these four lines:


Give it execute permission (chmod +x), and place it in <document root>/cgi-bin. Then open the following URL:


Expected result:
In the Environment table, I expect to see the following:

PATH_INFO        /extrapathinfo

Actual result:
PATH_INFO        no value
ORIG_PATH_INFO   /extrapathinfo

(PHP has copied the original PATH_INFO value to ORIG_PATH_INFO, and cleared PATH_INFO.)


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-09-20 11:13 UTC]
Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. 

Thank you for your interest in PHP.

See bug #31892

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Thu Oct 28 18:04:14 2021 UTC