PHP 4.0 Bug #7909 Updated: Avoiding unwanted "CGI" behaviour.

From: Date: Tue, 21 Nov 2000 20:55:55 +0000
Subject: PHP 4.0 Bug #7909 Updated: Avoiding unwanted "CGI" behaviour.
Groups: php.dev 
Request: Send a blank email to php-dev+get-38854@lists.php.net to get a copy of this message
ID: 7909 Updated by: dbeu Reported By: leif@roxen.com Status: Closed Bug Type: Feature/Change Request Assigned To: Comments: this is imo already fixed in cvs. try a snapshot http://snaps.php.net , and reopen if it's still existent Previous Comments: --------------------------------------------------------------------------- [2000-11-21 15:37:39] leif@roxen.com When invoking PHP from the command line, it accepts a file name as argument, and processes the contents of this file. When invoked from a CGI, the behaviour is different, and it doesn't accept command line arguments. So far, so good. However, when invoked from inside a CGI script, or similar circumstances, e.g. #! /bin/sh echo "X-My-Header: testing" echo "Content-type: text/plain" /usr/local/bin/php /my/script/file.php | tail +3 PHP incorrectly assumes it's being invoked as a CGI script interpreter, and ignores the command line argument, giving the completely misleading error message "No input file specified.". At the very least, this is a documentation problem, but it would be rather desirable if PHP could make better guesses as to whether it's being invoked as a real CGI or not. The current algorithm (in main() in sapi/cgi/cgi_main.c) bases its guess on whether any of the environment variables SERVER_SOFTWARE, SERVER_NAME, GATEWAY_INTERFACE and REQUEST_METHOD are defined. It's possible to circumvent the problem by undefining these variables before invoking PHP, but that obviously won't work if one wants to use the value of any of those variables in the script. If there is no easy way of improving the guessing strategy, one solution would be to follow the current guess by a test for an extra environment variable PHP_NO_CGI_PLEASE or something like that, and behave in the non-CGI way if it is set. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7909

« previous php.dev (#38854) next »