From: Kevin Israel Date: Thu, 3 Oct 2013 06:53:30 +0000 (-0400) Subject: Maintenance: detect missing parent::__construct() X-Git-Tag: 1.31.0-rc.0~18616^2 X-Git-Url: http://git.cyclocoop.org/fichier?a=commitdiff_plain;h=b0647c30bc30874cab25b17efc09ab876ef244ca;p=lhc%2Fweb%2Fwiklou.git Maintenance: detect missing parent::__construct() The first time I forgot to include that line in a maintenance script, I spent a few minutes debugging "Notice: Undefined variable: IP". Hopefully, this change will save someone else a few minutes of his or her own time. Change-Id: Icd26a5dc59e25d2bcc6da9bf0a2f6e95d494e5a6 --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 1712b24910..30e93c9017 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -477,13 +477,18 @@ abstract class Maintenance { * Do some sanity checking and basic setup */ public function setup() { - global $wgCommandLineMode, $wgRequestTime; + global $IP, $wgCommandLineMode, $wgRequestTime; # Abort if called from a web server if ( isset( $_SERVER ) && isset( $_SERVER['REQUEST_METHOD'] ) ) { $this->error( 'This script must be run from the command line', true ); } + if ( $IP === null ) { + $this->error( "\$IP not set, aborting!\n" . + '(Did you forget to call parent::__construct() in your maintenance script?)', 1 ); + } + # Make sure we can handle script parameters if ( !defined( 'HPHP_VERSION' ) && !ini_get( 'register_argc_argv' ) ) { $this->error( 'Cannot get command line arguments, register_argc_argv is set to false', true );