From: Chad Horohoe Date: Mon, 13 Dec 2010 15:30:41 +0000 (+0000) Subject: Fix for r75858: Move $IP detection further up so it can be used in child constructors X-Git-Tag: 1.31.0-rc.0~33339 X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=commitdiff_plain;h=495ea205640cc3594623e458ef3e5832e4bbd81f;p=lhc%2Fweb%2Fwiklou.git Fix for r75858: Move $IP detection further up so it can be used in child constructors --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 2c96c5260a..e1e0098a99 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -102,10 +102,16 @@ abstract class Maintenance { protected static $mCoreScripts = null; /** - * Default constructor. Children should call this if implementing + * Default constructor. Children should call this *first* if implementing * their own constructors */ public function __construct() { + // Setup $IP, using MW_INSTALL_PATH if it exists + global $IP; + $IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== '' + ? getenv( 'MW_INSTALL_PATH' ) + : realpath( dirname( __FILE__ ) . '/..' ); + $this->addDefaultParams(); register_shutdown_function( array( $this, 'outputChanneled' ), false ); } @@ -415,7 +421,7 @@ abstract class Maintenance { * Do some sanity checking and basic setup */ public function setup() { - global $IP, $wgCommandLineMode, $wgRequestTime; + global $wgCommandLineMode, $wgRequestTime; # Abort if called from a web server if ( isset( $_SERVER ) && isset( $_SERVER['REQUEST_METHOD'] ) ) { @@ -459,11 +465,6 @@ abstract class Maintenance { # Define us as being in MediaWiki define( 'MEDIAWIKI', true ); - # Setup $IP, using MW_INSTALL_PATH if it exists - $IP = strval( getenv( 'MW_INSTALL_PATH' ) ) !== '' - ? getenv( 'MW_INSTALL_PATH' ) - : realpath( dirname( __FILE__ ) . '/..' ); - $wgCommandLineMode = true; # Turn off output buffering if it's on @ob_end_flush();