Bug #51983 [Com]: [fpm sapi] pm.status_path not working when cgi.fix_pathinfo=1

From: Date: Fri, 04 Jun 2010 06:25:24 +0000
Subject: Bug #51983 [Com]: [fpm sapi] pm.status_path not working when cgi.fix_pathinfo=1
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-151076@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=51983&edit=1

 ID:               51983
 Comment by:       fat@php.net
 Reported by:      konstantin at symbi dot org
 Summary:          [fpm sapi] pm.status_path not working when
                   cgi.fix_pathinfo=1
 Status:           Assigned
 Type:             Bug
 Package:          FPM related
 Operating System: Any
 PHP Version:      5.3SVN-2010-06-03 (snap)
 Assigned To:      fat

 New Comment:

Have you tried your patch with other webservers than nginx and lighttpd
?


Previous Comments:
------------------------------------------------------------------------
[2010-06-04 06:32:12] sergo_s at bk dot ru

I met problem "No input file specified" in the configuration of lighttpd
1.4.26 + php-5.3.2 + fastcgi/php-fpm when requesting addresses like
index.php/myMethod/ (kohanaframework based site). I found that
$_SERVER[PATH_INFO] is NULL.
(More about my problem in this post:
http://phpclub.ru/talk/showthread.php?s=&postid=902382
(russian))

This patch solved the problem. Thanks.

------------------------------------------------------------------------
[2010-06-03 04:42:33] konstantin at symbi dot org

Description:
------------
FPM status does not work when cgi.fix_pathinfo = 1, with the default
nginx 
configuration for php (default fastcgi_params + SCRIPT_FILENAME added).

The problems is that in fpm_main.c, here:

if (!strcasecmp(SG(request_info).request_method, "GET") && 
fpm_status_handle_status(SG(request_info).request_uri, ...

SG(request_info).request_uri is sometimes NULL depending on the
trickiest things 
which happen when cgi.fix_pathinfo = 1.

I have examined the code of init_request_info() which runs when
cgi.fix_pathinfo 
= 1, and I found out that this part of code is legacy part from the CGI
SAPI, it 
is was designed to fix problems with a lots of broken CGI
implementations. It 
was reasonable for CGI to get the things working independent on speed,
but the 
'bruteforce' approach used is not too good for FPM SAPI which is
commonly used 
on high-bandwidth sites.

More, PHP introduces non-standard "SCRIPT_FILENAME" fastcgi env; it is
not hard 
to add it to configuration of flexible servers like nginx (by using 
"fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name" in
its 
configuration), but it can cause problems with such servers as lighttpd
where 
all the fastcgi parameters are hardcoded (I've seen people on forums
complaining 
thay get 'no input file' with nginx+fpm and they found no way to fix
it).

So, I have found the fix_pathinfo part is written in a hard to
understand and 
difficult to fix way, and that is is really not required for FPM SAPI,
and that 
it slows it down. System administrators who configure FSM webservers and
use FPM 
sapi are usually experianced and for them it would be preferable to have
strict 
and simple logic rather then some magic which can potentially slow
things down a 
lot. So i have rewritten init_request_info(), the the suggested patch is

attached.

It logic of detection script_filename is much simpler:
if SCRIPT_FILENAME is defined, use it,
else if both DOCUMENT_ROOT and SCRIPT_NAME are defined, concat them and
use 
(should fix all the problems with lighty etc);
else if PATH_TRALSLATED is defined, use it as script_filename;
else we do not know the script_filename.

And, of course, it fixes the problem with pm.status_path I started with.

Test script:
---------------
N/A

Expected result:
----------------
N/A

Actual result:
--------------
N/A


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



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


Thread (30 messages)

« previous php.bugs (#151076) next »