Add a way for packagers to override some installation details
...after a discussion with Debian packagers. They can now override installer classes and change LocalSettings.php the installer generates. The file intended for such overrides, mw-config/overrides.php, has intentionally been placed outside of includes to underline the "don't change includes" paradigm. Change-Id: Id82b90f6740307609bc6c6f4fb8765bc3484dbe7
This commit is contained in:
parent
abc2de3145
commit
63fb18bd4e
8 changed files with 81 additions and 15 deletions
|
|
@ -87,9 +87,9 @@ which the user can edit by hand thereafter. It's just a plain old PHP file,
|
|||
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.
|
||||
|
|
|
|||
|
|
@ -992,6 +992,9 @@ $wgAutoloadLocalClasses = array(
|
|||
'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',
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ class CliInstaller extends Installer {
|
|||
* @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" );
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,16 +29,16 @@
|
|||
*/
|
||||
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.
|
||||
|
|
@ -166,7 +166,7 @@ class LocalSettingsGenerator {
|
|||
/**
|
||||
* @return String
|
||||
*/
|
||||
private function buildMemcachedServerList() {
|
||||
protected function buildMemcachedServerList() {
|
||||
$servers = $this->values['_MemCachedServers'];
|
||||
|
||||
if( !$servers ) {
|
||||
|
|
@ -187,7 +187,7 @@ class LocalSettingsGenerator {
|
|||
/**
|
||||
* @return String
|
||||
*/
|
||||
private function getDefaultText() {
|
||||
protected function getDefaultText() {
|
||||
if( !$this->values['wgImageMagickConvertCommand'] ) {
|
||||
$this->values['wgImageMagickConvertCommand'] = '/usr/bin/convert';
|
||||
$magic = '#';
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ class WebInstaller extends Installer {
|
|||
'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 );
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ class CommandLineInstaller extends Maintenance {
|
|||
}
|
||||
|
||||
$installer =
|
||||
new CliInstaller( $siteName, $adminName, $this->mOptions );
|
||||
InstallerOverrides::getCliInstaller( $siteName, $adminName, $this->mOptions );
|
||||
|
||||
$status = $installer->doEnvironmentChecks();
|
||||
if( $status->isGood() ) {
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ wfInstallerMain();
|
|||
function wfInstallerMain() {
|
||||
global $wgRequest, $wgLang, $wgMetaNamespace, $wgCanonicalNamespaceNames;
|
||||
|
||||
$installer = new WebInstaller( $wgRequest );
|
||||
$installer = InstallerOverrides::getWebInstaller( $wgRequest );
|
||||
|
||||
if ( !$installer->startSession() ) {
|
||||
$installer->finish();
|
||||
|
|
|
|||
63
mw-config/overrides.php
Normal file
63
mw-config/overrides.php
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?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 );
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue