From: Tim Starling Date: Fri, 8 Dec 2017 04:34:23 +0000 (+1100) Subject: Fix maintenance script failure when run as a child of a FastCGI worker X-Git-Tag: 1.31.0-rc.0~1248^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22auteur_infos%22%2C%22id_auteur=%24connect_id_auteur%22%29%20.%20%22?a=commitdiff_plain;h=659f3779c33748ac66fb307e639648d839580130;p=lhc%2Fweb%2Fwiklou.git Fix maintenance script failure when run as a child of a FastCGI worker 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 --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 255892b52d..a3e0ffd917 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -662,7 +662,7 @@ abstract class Maintenance { 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' ); }