ID: 31843 Updated by: [EMAIL PROTECTED] Reported By: ceefour at gauldong dot net -Status: Open +Status: Bogus Bug Type: CGI related Operating System: Apache/1.3.33 (Unix) mod_ssl/2.8 PHP Version: 4.3.10 New Comment:
I did not say anything about any patch in my _first_ comment. Try reading comprehension once.. Previous Comments: ------------------------------------------------------------------------ [2005-02-05 14:54:26] ceefour at gauldong dot net Hi! I don't see any relation about this bug with the patch/bug you said. This bug is related to (actually it is) PHP_SELF. While the patch fixes PATH_INFO/SCRIPT_FILENAME/whatever... which has no relation whatsoever. And actually, it should NOT have a relation to PATH_INFO since PHP_SELF is NOT related to PATH_INFO, but it turns out it SEEM TO have a relation to PATH_INFO as of PHP 4.3.10 CGI (as they actually have the exact same value, which is incorrect behavior). Please explain why you claimed your patch fixes this bug??? ------------------------------------------------------------------------ [2005-02-04 17:05:51] [EMAIL PROTECTED] Please don't send me any private emails, use this: http://bugs.php.net/bug.php?id=31843&edit=2 And read my first comment to this bug report too.. (you can find the same text in php.ini-dist file) ------------------------------------------------------------------------ [2005-02-04 11:47:33] [EMAIL PROTECTED] Check this out: ; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI. PHP's ; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok ; what PATH_INFO is. 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. A setting ; of zero causes PHP to behave as before. Default is zero. You should fix your scripts ; to use SCRIPT_FILENAME rather than PATH_TRANSLATED. ; cgi.fix_pathinfo=0 ------------------------------------------------------------------------ [2005-02-04 10:58:38] ceefour at gauldong dot net Description: ------------ First of all, let me say this is a very old bug (over two years old). There are references all over the net for this, but here's what I found inside PHP's bug report: http://bugs.php.net/bug.php?id=14307 http://bugs.php.net/bug.php?id=18942 http://bugs.php.net/bug.php?id=8252 The most related bug (actually this exact bug) is Bug #18942: $PHP_SELF is set to HTTP_SERVER_VARS[PATH_INFO] if available. The response (which I think is pure bogus) is: ------------- This bug has been fixed in CVS. ... It's fixed in cvs as of today. ------------- well, that "today" is somehow over two years ago. ;-) Anyway, the problem is simple. Considering this script: http://www.gauldong.net/phpinfo.php/test In other than CGI mode, PHP_SELF will be "/phpinfo.php/test", which is correct. But in CGI mode, PHP_SELF will be "/test", which is incorrect. Since it does not refer to the URI of the current script, but rather the PATH_INFO. You can test it for yourself. The above URL I provided as an example is real, it's not just there for an example. So try it. You can scroll down to the the middle of the page to find out the value of PHP_SELF, but an easier and quicker way is just to look whether the PHP/Zend images load. Well, they don't, since they use PHP_SELF which has an incorrect value. My workaround for this bug is as follows (not how handling this special quirk is *SOOOO* unnecessary): /** * Returns URI of currently executing PHP script. * * I noticed some weirdness in PHP behaviour (maybe related to operating system and/or Apache version/platform). * In my WinXP box PHP_SELF works fine. But in Linux production server PHP_SELF is the same as PATH_INFO * and SCRIPT_URL seems to contain the real correct PHP_SELF. However, SCRIPT_URL does not exist in my WinXP box. * So I guess the the only thing that is common in two servers is the REQUEST_URI server variable. So I parse * this using parse_url() and returns the path portion. * * @access public * @static This method can be called statically. * @see GetServer() * @return string PHP script URI. */ /*public static*/ function GetSelf() { if (!Types::IsEmpty($_SERVER['SCRIPT_URL'])) { return $_SERVER['SCRIPT_URL']; } else { $uri = $_SERVER['REQUEST_URI']; $parsed = @parse_url($uri); if (isset($parsed)) return $parsed['path']; else return $_SERVER['PHP_SELF']; } } Reproduce code: --------------- echo $_SERVER['PHP_SELF']; Expected result: ---------------- /phpinfo.php/test Actual result: -------------- /test ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=31843&edit=1