Use PHP_SAPI==cli instead of checking $_SERVER['REQUEST_METHOD'],
since $_SERVER is populated from the environment when running HHVM in
CLI mode. Environment variables set by a FastCGI worker thus leak
through to child processes run via the shell, and cause this check to
fail.
When I wrote this check in March 2004 (r2803), I didn't know about
PHP_SAPI. Checking PHP_SAPI is quite sufficient to prevent web execution,
we use it in other places.
Bug: T111441
Change-Id: Iad8469ee25df4b0e0c2371e7975a300b1695dd8d
global $IP, $wgCommandLineMode, $wgRequestTime;
# Abort if called from a web server
- if ( isset( $_SERVER ) && isset( $_SERVER['REQUEST_METHOD'] ) ) {
+ if ( PHP_SAPI !== 'cli' ) {
$this->fatalError( 'This script must be run from the command line' );
}