From: Aryeh Gregor Date: Tue, 9 Apr 2019 07:52:38 +0000 (+0300) Subject: Set MW_INSTALL_PATH in Maintenance.php X-Git-Tag: 1.34.0-rc.0~2027^2 X-Git-Url: http://git.cyclocoop.org/data/%27%20.%20mediabox_timestamp%28find_in_path%28%27javascript/%7B%24www_url%7Dadmin/compta/operations/%40%20%27info_etape_suivante_2%27%20=%3E%20%27You%20can%20move%20on%20to%20the%20next%20step.%27%2C%20%27info_exceptions_proxy%27%20=%3E%20%27Exceptions%20for%20the%20proxy%27%2C%20%27info_exportation_base%27%20=%3E%20%27export%20database%20to%20%40archive%40%27%2C-%27info_facilite_suivi_activite%27%20=%3E%20%27To%20simplify%20monitoring%20of%20the%20site/%27s%20editorial;-%20%20activities%2C%20SPIP%20can%20send%20rmail%20notifications%2C%20e.g.%20to%20an%20editors/%27.%28%24current%20%3E%202?a=commitdiff_plain;h=b46a32c85f192f122554280a550bd35b41588e73;p=lhc%2Fweb%2Fwiklou.git Set MW_INSTALL_PATH in Maintenance.php Otherwise, if running update.php, there are require_once failures from extensions (at least Echo and Flow) if they aren't inside extensions/ -- e.g., if they're just symlinked from there. Change-Id: Iaf4231abae1621627f01171f955b5bb7a0fa77d8 --- diff --git a/maintenance/Maintenance.php b/maintenance/Maintenance.php index 0d4f14c812..c0dd7f8ed3 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 );