Bug #67998 [Opn->Nab]: Wrong SCRIPT_FILENAME
| From: | bukka@php.net | Date: | Fri, 07 Apr 2023 11:40:33 +0000 |
| Subject: | Bug #67998 [Opn->Nab]: Wrong SCRIPT_FILENAME | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-244138@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=67998&edit=1
ID: 67998
Updated by: bukka@php.net
Reported by: php-fpm1 at gmail dot com
Summary: Wrong SCRIPT_FILENAME
-Status: Open
+Status: Not a bug
Type: Bug
Package: FPM related
Operating System: CentOS6
PHP Version: 5.4.32
-Assigned To:
+Assigned To: bukka
Block user comment: N
Private report: N
New Comment:
I just did a little bit of debugging and this is what Apache sends as SCRIPT_FILENAME if the
trailing slash is supplied:
proxy:fcgi://localhost//home/jakub/prog/php/tests/fpm/fcgi-envs/index.php
if my Apache config is
SetHandler
"proxy:unix:/home/jakub/prog/php/tests/fpm/fcgi-envs/fpm.sock|fcgi://localhost/"
It should not be really a problem functionality wise on Linux as multiple slashes are equivalent to
a single one. But to have variable as expected the solution is to really set it without trailing
slash in Apache config. If anything it is a bug in the Apache docs or maybe in its code (looks more
docs issue to me). Nothing should be done about it in FPM though.
Previous Comments:
------------------------------------------------------------------------
[2014-09-11 05:33:26] dz at heroku dot com
The docs are wrong. Don't add a trailing slash. The request URI is appended to whatever you
provide in SetHandler.
The use of UDS may also further confuse things as PHP doesn't handle that.
------------------------------------------------------------------------
[2014-09-10 15:50:21] phpfpm1 at gmail dot com
BTW, PHP-FPM is setup using unix domain sockets in Apache.
AddHandler "proxy:unix:/usr/local/php54/sockets/admin.sock|fcgi://localhost/" .inc .php
.phtml .php54
More info: http://httpd.apache.org/docs/current/mod/mod_proxy.html#handler
I've found that the following fixes the problem (removing "/" from the end of
"localhost"):
AddHandler "proxy:unix:/usr/local/php54/sockets/admin.sock|fcgi://localhost" .inc .php
.phtml .php54
But official Apache documentation states that "/" ending should be there.
------------------------------------------------------------------------
[2014-09-10 14:22:38] phpfpm1 at gmail dot com
I forgot to mention that the bug affects PHP 5.4.33RC1 too, so https://bugs.php.net/bug.php?id=67541 doesn't
fix it.
------------------------------------------------------------------------
[2014-09-10 14:15:39] php-fpm1 at gmail dot com
Description:
------------
Wrong SCIPRT_FILENAME is given. It contains '/' twice at the start of it (//).
["SCRIPT_FILENAME"]=> string(57)
"//home/admin/domains/testing.domain.tld/public_html/test.php"
Other variables are okay:
["CONTEXT_DOCUMENT_ROOT"]=> string(47)
"/home/admin/domains/testing.domain.tld/public_html"
["DOCUMENT_ROOT"]=> string(47)
"/home/admin/domains/testing.domain.tld/public_html"
["REQUEST_URI"]=> string(9) "/test.php"
["SCRIPT_NAME"]=> string(9) "/test.php"
["PHP_SELF"]=> string(9) "/test.php"
["HOME"]=> string(11) "/home/admin"
It also breaks SG(request_info).path_translated in extensions.
Test script:
---------------
<?php
echo $_SERVER;
?>
Expected result:
----------------
["SCRIPT_FILENAME"]=> string(57)
"/home/admin/domains/testing.domain.tld/public_html/test.php"
Actual result:
--------------
["SCRIPT_FILENAME"]=> string(57)
"//home/admin/domains/testing.domain.tld/public_html/test.php"
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67998&edit=1