and can contain any PHP statements. It usually sets global variables that are
used for configuration, and includes files used by any extensions.
-Distributors cannot easily add extra statements to the autogenerated
-LocalSettings.php at the present time -- although hacking mw-config/index.php
-would work. It would be nice if this situation could be improved.
+Distributors can easily add extra statements to the autogenerated
+LocalSettings.php by changing mw-config/overrides.php (see that file for details
+and examples).
There's a new maintenance/install.php script which could be used for performing
an install through the command line.
'AnsiTermColorer' => 'maintenance/term/MWTerm.php',
'DummyTermColorer' => 'maintenance/term/MWTerm.php',
+ # mw-config
+ 'InstallerOverrides' => 'mw-config/overrides.php',
+
# tests
'DbTestPreviewer' => 'tests/testHelpers.inc',
'DbTestRecorder' => 'tests/testHelpers.inc',
* @param $path String Full path to write LocalSettings.php to
*/
public function writeConfigurationFile( $path ) {
- $ls = new LocalSettingsGenerator( $this );
+ $ls = InstallerOverrides::getLocalSettingsGenerator( $this );
$ls->writeFile( "$path/LocalSettings.php" );
}
*/
class LocalSettingsGenerator {
- private $extensions = array();
- private $values = array();
- private $groupPermissions = array();
- private $dbSettings = '';
- private $safeMode = false;
+ protected $extensions = array();
+ protected $values = array();
+ protected $groupPermissions = array();
+ protected $dbSettings = '';
+ protected $safeMode = false;
/**
* @var Installer
*/
- private $installer;
+ protected $installer;
/**
* Constructor.
/**
* @return String
*/
- private function buildMemcachedServerList() {
+ protected function buildMemcachedServerList() {
$servers = $this->values['_MemCachedServers'];
if( !$servers ) {
/**
* @return String
*/
- private function getDefaultText() {
+ protected function getDefaultText() {
if( !$this->values['wgImageMagickConvertCommand'] ) {
$this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
$magic = '#';
'Content-Disposition: attachment; filename="LocalSettings.php"'
);
- $ls = new LocalSettingsGenerator( $this );
+ $ls = InstallerOverrides::getLocalSettingsGenerator( $this );
$rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
foreach( $rightsProfile as $group => $rightsArr ) {
$ls->setGroupRights( $group, $rightsArr );
}
$installer =
- new CliInstaller( $siteName, $adminName, $this->mOptions );
+ InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
$status = $installer->doEnvironmentChecks();
if( $status->isGood() ) {
function wfInstallerMain() {
global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
- $installer = new WebInstaller( $wgRequest );
+ $installer = InstallerOverrides::getWebInstaller( $wgRequest );
if ( !$installer->startSession() ) {
$installer->finish();
--- /dev/null
+<?php
+/**
+ * MediaWiki installer overrides.
+ * Modify this file if you are a packager who needs to modify the behavior of the MediaWiki installer.
+ * Altering it is preferred over changing anything in /includes.
+ *
+ * Note: this file doesn't gets included from a global scope, don't use globals directly.
+ */
+
+/*
+
+Example of modifications:
+
+ public static function getLocalSettingsGenerator( Installer $installer ) {
+ return new MyLocalSettingsGenerator( $installer );
+ }
+
+Then add the following to the bottom of this file:
+
+class MyLocalSettingsGenerator extends LocalSettingsGenerator {
+ function getText() {
+ // Modify an existing setting
+ $this->values['wgResourceLoaderMaxQueryLength'] = 512;
+ // add a new setting
+ $ls = parent::getText();
+ return $ls . "\n\$wgUseTex = true;\n";
+ }
+}
+*/
+
+/**
+ * @since 1.20
+ */
+class InstallerOverrides {
+ /**
+ * Instantiates and returns an instance of LocalSettingsGenerator or its descendant classes
+ * @param Installer $installer
+ * @return LocalSettingsGenerator
+ */
+ public static function getLocalSettingsGenerator( Installer $installer ) {
+ return new LocalSettingsGenerator( $installer );
+ }
+
+ /**
+ * Instantiates and returns an instance of WebInstaller or its descendant classes
+ * @param WebRequest $request
+ * @return WebInstaller
+ */
+ public static function getWebInstaller( WebRequest $request ) {
+ return new WebInstaller( $request );
+ }
+
+ /**
+ * Instantiates and returns an instance of CliInstaller or its descendant classes
+ * @param string $siteName
+ * @param string|null $admin
+ * @param array $options
+ * @return CliInstaller
+ */
+ public static function getCliInstaller( $siteName, $admin = null, array $options = array() ) {
+ return new CliInstaller( $siteName, $admin, $options );
+ }
+}