From 659f3779c33748ac66fb307e639648d839580130 Mon Sep 17 00:00:00 2001 From: Tim Starling Date: Fri, 8 Dec 2017 15:34:23 +1100 Subject: [PATCH 1/1] 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 --- maintenance/Maintenance.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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' ); } -- 2.20.1