/**
* Base code for MediaWiki installer.
*
+ * DO NOT PATCH THIS FILE IF YOU NEED TO CHANGE INSTALLER BEHAVIOR IN YOUR PACKAGE!
+ * See mw-config/overrides/README for details.
+ *
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* @file
* @ingroup Deployment
*/
+use MediaWiki\MediaWikiServices;
/**
* This documentation group collects source code files with deployment functionality.
protected $envChecks = [
'envCheckDB',
'envCheckBrokenXML',
- 'envCheckMbstring',
- 'envCheckXML',
'envCheckPCRE',
'envCheckMemory',
'envCheckCache',
'envCheckUploadsDirectory',
'envCheckLibicu',
'envCheckSuhosinMaxValueLength',
- 'envCheckCtype',
- 'envCheckIconv',
- 'envCheckJSON',
];
/**
*/
abstract public function showStatusMessage( Status $status );
+ /**
+ * Constructs a Config object that contains configuration settings that should be
+ * overwritten for the installation process.
+ *
+ * @since 1.27
+ *
+ * @param Config $baseConfig
+ *
+ * @return Config The config to use during installation.
+ */
+ public static function getInstallerConfig( Config $baseConfig ) {
+ $configOverrides = new HashConfig();
+
+ // disable (problematic) object cache types explicitly, preserving all other (working) ones
+ // bug T113843
+ $emptyCache = [ 'class' => 'EmptyBagOStuff' ];
+
+ $objectCaches = [
+ CACHE_NONE => $emptyCache,
+ CACHE_DB => $emptyCache,
+ CACHE_ANYTHING => $emptyCache,
+ CACHE_MEMCACHED => $emptyCache,
+ ] + $baseConfig->get( 'ObjectCaches' );
+
+ $configOverrides->set( 'ObjectCaches', $objectCaches );
+
+ // Load the installer's i18n.
+ $messageDirs = $baseConfig->get( 'MessagesDirs' );
+ $messageDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
+
+ $configOverrides->set( 'MessagesDirs', $messageDirs );
+
+ $installerConfig = new MultiConfig( [ $configOverrides, $baseConfig ] );
+
+ // make sure we use the installer config as the main config
+ $configRegistry = $baseConfig->get( 'ConfigRegistry' );
+ $configRegistry['main'] = function() use ( $installerConfig ) {
+ return $installerConfig;
+ };
+
+ $configOverrides->set( 'ConfigRegistry', $configRegistry );
+
+ return $installerConfig;
+ }
+
/**
* Constructor, always call this from child classes.
*/
public function __construct() {
- global $wgMessagesDirs, $wgUser;
+ global $wgMemc, $wgUser, $wgObjectCaches;
+
+ $defaultConfig = new GlobalVarConfig(); // all the stuff from DefaultSettings.php
+ $installerConfig = self::getInstallerConfig( $defaultConfig );
+
+ // Reset all services and inject config overrides
+ MediaWiki\MediaWikiServices::resetGlobalInstance( $installerConfig );
// Don't attempt to load user language options (T126177)
// This will be overridden in the web installer with the user-specified language
RequestContext::getMain()->setLanguage( 'en' );
// Disable the i18n cache
+ // TODO: manage LocalisationCache singleton in MediaWikiServices
Language::getLocalisationCache()->disableBackend();
- // Disable LoadBalancer and wfGetDB etc.
- LBFactory::disableBackend();
+
+ // Disable all global services, since we don't have any configuration yet!
+ MediaWiki\MediaWikiServices::disableStorageBackend();
// Disable object cache (otherwise CACHE_ANYTHING will try CACHE_DB and
// SqlBagOStuff will then throw since we just disabled wfGetDB)
- $GLOBALS['wgMemc'] = new EmptyBagOStuff;
- ObjectCache::clear();
- $emptyCache = [ 'class' => 'EmptyBagOStuff' ];
- // disable (problematic) object cache types explicitly, preserving all other (working) ones
- // bug T113843
- $GLOBALS['wgObjectCaches'] = [
- CACHE_NONE => $emptyCache,
- CACHE_DB => $emptyCache,
- CACHE_ANYTHING => $emptyCache,
- CACHE_MEMCACHED => $emptyCache,
- ] + $GLOBALS['wgObjectCaches'];
-
- // Load the installer's i18n.
- $wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
+ $wgObjectCaches = MediaWikiServices::getInstance()->getMainConfig()->get( 'ObjectCaches' );
+ $wgMemc = ObjectCache::getInstance( CACHE_NONE );
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId( 0 );
return true;
}
- /**
- * Environment check for mbstring.func_overload.
- * @return bool
- */
- protected function envCheckMbstring() {
- if ( wfIniGetBool( 'mbstring.func_overload' ) ) {
- $this->showError( 'config-mbstring' );
-
- return false;
- }
-
- if ( !function_exists( 'mb_substr' ) ) {
- $this->showError( 'config-mbstring-absent' );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Environment check for the XML module.
- * @return bool
- */
- protected function envCheckXML() {
- if ( !function_exists( "utf8_encode" ) ) {
- $this->showError( 'config-xml-bad' );
-
- return false;
- }
-
- return true;
- }
-
/**
* Environment check for the PCRE module.
*
}
}
- /**
- * @return bool
- */
- protected function envCheckCtype() {
- if ( !function_exists( 'ctype_digit' ) ) {
- $this->showError( 'config-ctype' );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * @return bool
- */
- protected function envCheckIconv() {
- if ( !function_exists( 'iconv' ) ) {
- $this->showError( 'config-iconv' );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * @return bool
- */
- protected function envCheckJSON() {
- if ( !function_exists( 'json_decode' ) ) {
- $this->showError( 'config-json' );
-
- return false;
- }
-
- return true;
- }
-
/**
* Environment prep for the server hostname.
*/
$command = $path . DIRECTORY_SEPARATOR . $name;
MediaWiki\suppressWarnings();
- $file_exists = file_exists( $command );
+ $file_exists = is_executable( $command );
MediaWiki\restoreWarnings();
if ( $file_exists ) {
wfMessage( 'mainpagedocfooter' )->inContentLanguage()->text()
);
- $page->doEditContent( $content,
+ $status = $page->doEditContent( $content,
'',
EDIT_NEW,
false,