Bug #76529 [Opn->Ver]: php-cgi: -C option ignored
| From: | ab@php.net | Date: | Wed, 27 Jun 2018 20:20:55 +0000 |
| Subject: | Bug #76529 [Opn->Ver]: php-cgi: -C option ignored | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215994@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76529&edit=1
ID: 76529
Updated by: ab@php.net
Reported by: shhsu at microsoft dot com
Summary: php-cgi: -C option ignored
-Status: Open
+Status: Verified
Type: Bug
Package: *General Issues
Operating System: Windows
PHP Version: 7.2.7
Block user comment: N
Private report: N
New Comment:
Thanks for the report. You're rigt, -C is only taken in account when php-cgi.exe is run on
console, like the most of the options. It seems to be indeed by design, as the surrounding condition
is "if (!cgi && !fastcgi) {". This likely to be fixed easily by moving the case a
couple of lines above into another switch https://github.com/php/php-src/blob/5f58f5ccf0909a90baef1280c3826f96b8e133ee/sapi/cgi/cgi_main.c#L2293
. It seems to be a crossplatform behavior, not IIS specific.
I'm a bit reluctant on changing this right away, because there might be other implication in
performance and compatibility with some legacy PHP code. Right now the 7.3 feature freeze is less
than a week away and changing this behavior might have a beyond impact. It would be good to hear
more opinions and to consider a fix for the next minor version.
Thanks.
Previous Comments:
------------------------------------------------------------------------
[2018-06-25 20:36:57] shhsu at microsoft dot com
Description:
------------
Hi
We are trying to benchmark PHP performance under IIS. We noticed that PHP is trying to chdir to
script directory and that is causing a lot of contention because it's IO bound.
To workaround this. I tried to pass "-C" option to php-cgi.exe. (Process run as:
"php-cgi.exe -C" However, I am still observing chdir taking place.
P.S. I noticed that php_execute_script
(https://github.com/php/php-src/blob/5f58f5ccf0909a90baef1280c3826f96b8e133ee/main/main.c#L2496)
gets executed before zend_first_try
(https://github.com/php/php-src/blob/5f58f5ccf0909a90baef1280c3826f96b8e133ee/sapi/cgi/cgi_main.c#L2356)
where the -C option is processed. Not sure if this is by design.
Test script:
---------------
Setup PHP for IIS. Add the following configuration
</system.webServer>
<fastCgi>
<application fullPath="C:\php-7.2.7-nts-Win32-VC15\php-cgi.exe"
arguments="-C" maxInstances="10" instanceMaxRequests="10000000"
queueLength="10000">
<environmentVariables>
<environmentVariable name="PHP_FCGI_MAX_REQUESTS"
value="10000000" />
<environmentVariable name="PHPRC"
value="C:\php-7.2.7-nts-Win32-VC15" />
</environmentVariables>
</application>
</fastCgi>
</system.webServer>
<location path="" overrideMode="Allow">
<system.webServer>
<handlers accessPolicy="Read, Script">
<add name="PHP-iisfcgi" path="*.php"
verb="GET,HEAD,POST" modules="FastCgiModule"
scriptProcessor="C:\php-7.2.7-nts-Win32-VC15\php-cgi.exe|-C"
resourceType="Either" />
</system.webServer>
....
</location>
Expected result:
----------------
If I execute php-cgi with -C, no chdir to script path should take place
Actual result:
--------------
chdir to script path
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76529&edit=1