From: jenkins-bot Date: Fri, 12 Apr 2019 20:34:45 +0000 (+0000) Subject: Merge "Set MW_INSTALL_PATH in Maintenance.php" X-Git-Tag: 1.34.0-rc.0~2027 X-Git-Url: http://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/operations/?a=commitdiff_plain;h=166389272390f58ea04886d561831aff35303078;hp=affd1dd473c3c453ad68e362385cba17ef9b11f1;p=lhc%2Fweb%2Fwiklou.git Merge "Set MW_INSTALL_PATH in Maintenance.php" --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 1cca26e63b..c88a1a0204 100644 --- a/maintenance/Maintenance.php +++ b/maintenance/Maintenance.php @@ -42,6 +42,13 @@ define( 'DO_MAINTENANCE', RUN_MAINTENANCE_IF_MAIN ); // original name, harmless $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 @@ 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 );