Merge "Set MW_INSTALL_PATH in Maintenance.php"
authorjenkins-bot <jenkins-bot@gerrit.wikimedia.org>
Fri, 12 Apr 2019 20:34:45 +0000 (20:34 +0000)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 12 Apr 2019 20:34:45 +0000 (20:34 +0000)
1  2 
maintenance/Maintenance.php

@@@ -42,6 -42,13 +42,13 @@@ define( 'DO_MAINTENANCE', RUN_MAINTENAN
  
  $maintClass = false;
  
+ // Some extensions rely on MW_INSTALL_PATH to find core files to include. Setting it here helps them
+ // if they're included by a core script (like DatabaseUpdater) after Maintenance.php has already
+ // been run.
+ if ( strval( getenv( 'MW_INSTALL_PATH' ) ) === '' ) {
+       putenv( 'MW_INSTALL_PATH=' . realpath( __DIR__ . '/..' ) );
+ }
  use Wikimedia\Rdbms\IDatabase;
  use MediaWiki\Logger\LoggerFactory;
  use MediaWiki\MediaWikiServices;
@@@ -171,11 -178,8 +178,8 @@@ abstract class Maintenance 
         * 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( __DIR__ . '/..' );
+               $IP = getenv( 'MW_INSTALL_PATH' );
  
                $this->addDefaultParams();
                register_shutdown_function( [ $this, 'outputChanneled' ], false );
                }
  
                /**
 -               * @var $child Maintenance
 +               * @var Maintenance $child
                 */
                $child = new $maintClass();
                $child->loadParamsAndArgs( $this->mSelf, $this->mOptions, $this->mArgs );
  
                        if ( $wgDBservers ) {
                                /**
 -                               * @var $wgDBservers array
 +                               * @var array $wgDBservers
                                 */
                                foreach ( $wgDBservers as $i => $server ) {
                                        $wgDBservers[$i]['user'] = $wgDBuser;