php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #7909 Avoiding unwanted "CGI" behaviour.
Submitted: 2000-11-21 15:37 UTC Modified: 2000-11-21 15:55 UTC
From: leif at roxen dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 4.0.3pl1 OS:
Private report: No CVE-ID: None
 [2000-11-21 15:37 UTC] leif at roxen dot 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.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-21 15:55 UTC] dbeu@php.net
this is imo already fixed in cvs.
try a snapshot http://snaps.php.net , and reopen if it's still existent
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 11 00:01:31 2024 UTC