summaryrefslogtreecommitdiff
path: root/includes/installer/Installer.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/installer/Installer.php')
-rw-r--r--includes/installer/Installer.php457
1 files changed, 228 insertions, 229 deletions
diff --git a/includes/installer/Installer.php b/includes/installer/Installer.php
index a9908134..d2651ae5 100644
--- a/includes/installer/Installer.php
+++ b/includes/installer/Installer.php
@@ -38,9 +38,6 @@
*/
abstract class Installer {
- // This is the absolute minimum PHP version we can support
- const MINIMUM_PHP_VERSION = '5.3.2';
-
/**
* The oldest version of PCRE we can support.
*
@@ -71,7 +68,7 @@ abstract class Installer {
/**
* Minimum memory size in MB.
*
- * @var integer
+ * @var int
*/
protected $minMemorySize = 50;
@@ -102,6 +99,7 @@ abstract class Installer {
'mysql',
'postgres',
'oracle',
+ 'mssql',
'sqlite',
);
@@ -110,17 +108,18 @@ abstract class Installer {
* These may output warnings using showMessage(), and/or abort the
* installation process by returning false.
*
+ * For the WebInstaller these are only called on the Welcome page,
+ * if these methods have side-effects that should affect later page loads
+ * (as well as the generated stylesheet), use envPreps instead.
+ *
* @var array
*/
protected $envChecks = array(
'envCheckDB',
'envCheckRegisterGlobals',
'envCheckBrokenXML',
- 'envCheckPHP531',
'envCheckMagicQuotes',
- 'envCheckMagicSybase',
'envCheckMbstring',
- 'envCheckZE1',
'envCheckSafeMode',
'envCheckXML',
'envCheckPCRE',
@@ -132,16 +131,27 @@ abstract class Installer {
'envCheckGit',
'envCheckServer',
'envCheckPath',
- 'envCheckExtension',
'envCheckShellLocale',
'envCheckUploadsDirectory',
'envCheckLibicu',
'envCheckSuhosinMaxValueLength',
'envCheckCtype',
+ 'envCheckIconv',
'envCheckJSON',
);
/**
+ * A list of environment preparation methods called by doEnvironmentPreps().
+ *
+ * @var array
+ */
+ protected $envPreps = array(
+ 'envPrepExtension',
+ 'envPrepServer',
+ 'envPrepPath',
+ );
+
+ /**
* MediaWiki configuration globals that will eventually be passed through
* to LocalSettings.php. The names only are given here, the defaults
* typically come from DefaultSettings.php.
@@ -171,7 +181,6 @@ abstract class Installer {
'wgMetaNamespace',
'wgDeletedDirectory',
'wgEnableUploads',
- 'wgLogo',
'wgShellLocale',
'wgSecretKey',
'wgUseInstantCommons',
@@ -201,7 +210,7 @@ abstract class Installer {
'_NamespaceType' => 'site-name',
'_AdminName' => '', // will be set later, when the user selects language
'_AdminPassword' => '',
- '_AdminPassword2' => '',
+ '_AdminPasswordConfirm' => '',
'_AdminEmail' => '',
'_Subscribe' => false,
'_SkipOptional' => 'continue',
@@ -209,9 +218,14 @@ abstract class Installer {
'_LicenseCode' => 'none',
'_CCDone' => false,
'_Extensions' => array(),
+ '_Skins' => array(),
'_MemCachedServers' => '',
'_UpgradeKeySupplied' => false,
'_ExistingDBSettings' => false,
+
+ // $wgLogo is probably wrong (bug 48084); set something that will work.
+ // Single quotes work fine here, as LocalSettingsGenerator outputs this unescaped.
+ 'wgLogo' => '$wgScriptPath/resources/assets/wiki.png',
);
/**
@@ -272,27 +286,27 @@ abstract class Installer {
public $licenses = array(
'cc-by' => array(
'url' => 'http://creativecommons.org/licenses/by/3.0/',
- 'icon' => '{$wgStylePath}/common/images/cc-by.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by.png',
),
'cc-by-sa' => array(
'url' => 'http://creativecommons.org/licenses/by-sa/3.0/',
- 'icon' => '{$wgStylePath}/common/images/cc-by-sa.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-sa.png',
),
'cc-by-nc-sa' => array(
'url' => 'http://creativecommons.org/licenses/by-nc-sa/3.0/',
- 'icon' => '{$wgStylePath}/common/images/cc-by-nc-sa.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-by-nc-sa.png',
),
'cc-0' => array(
'url' => 'https://creativecommons.org/publicdomain/zero/1.0/',
- 'icon' => '{$wgStylePath}/common/images/cc-0.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/cc-0.png',
),
'pd' => array(
'url' => '',
- 'icon' => '{$wgStylePath}/common/images/public-domain.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/public-domain.png',
),
'gfdl' => array(
'url' => 'http://www.gnu.org/copyleft/fdl.html',
- 'icon' => '{$wgStylePath}/common/images/gnu-fdl.png',
+ 'icon' => '{$wgResourceBasePath}/resources/assets/licenses/gnu-fdl.png',
),
'none' => array(
'url' => '',
@@ -327,19 +341,19 @@ abstract class Installer {
* The parameters are like parameters to wfMessage().
* The messages will be in wikitext format, which will be converted to an
* output format such as HTML or text before being sent to the user.
- * @param $msg
+ * @param string $msg
*/
abstract public function showMessage( $msg /*, ... */ );
/**
* Same as showMessage(), but for displaying errors
- * @param $msg
+ * @param string $msg
*/
abstract public function showError( $msg /*, ... */ );
/**
* Show a message to the installing user by using a Status object
- * @param $status Status
+ * @param Status $status
*/
abstract public function showStatusMessage( Status $status );
@@ -347,15 +361,27 @@ abstract class Installer {
* Constructor, always call this from child classes.
*/
public function __construct() {
- global $wgExtensionMessagesFiles, $wgUser;
+ global $wgMessagesDirs, $wgUser;
- // Disable the i18n cache and LoadBalancer
+ // Disable the i18n cache
Language::getLocalisationCache()->disableBackend();
+ // Disable LoadBalancer and wfGetDB etc.
LBFactory::disableBackend();
- // Load the installer's i18n file.
- $wgExtensionMessagesFiles['MediawikiInstaller'] =
- __DIR__ . '/Installer.i18n.php';
+ // 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 = array( 'class' => 'EmptyBagOStuff' );
+ $GLOBALS['wgObjectCaches'] = array(
+ CACHE_NONE => $emptyCache,
+ CACHE_DB => $emptyCache,
+ CACHE_ANYTHING => $emptyCache,
+ CACHE_MEMCACHED => $emptyCache,
+ );
+
+ // Load the installer's i18n.
+ $wgMessagesDirs['MediawikiInstaller'] = __DIR__ . '/i18n';
// Having a user with id = 0 safeguards us from DB access via User::loadOptions().
$wgUser = User::newFromId( 0 );
@@ -366,29 +392,20 @@ abstract class Installer {
$this->settings[$var] = $GLOBALS[$var];
}
- $compiledDBs = array();
+ $this->doEnvironmentPreps();
+
+ $this->compiledDBs = array();
foreach ( self::getDBTypes() as $type ) {
$installer = $this->getDBInstaller( $type );
if ( !$installer->isCompiled() ) {
continue;
}
- $compiledDBs[] = $type;
-
- $defaults = $installer->getGlobalDefaults();
-
- foreach ( $installer->getGlobalNames() as $var ) {
- if ( isset( $defaults[$var] ) ) {
- $this->settings[$var] = $defaults[$var];
- } else {
- $this->settings[$var] = $GLOBALS[$var];
- }
- }
+ $this->compiledDBs[] = $type;
}
- $this->compiledDBs = $compiledDBs;
$this->parserTitle = Title::newFromText( 'Installer' );
- $this->parserOptions = new ParserOptions; // language will be wrong :(
+ $this->parserOptions = new ParserOptions; // language will be wrong :(
$this->parserOptions->setEditSection( false );
}
@@ -415,25 +432,21 @@ abstract class Installer {
* @return Status
*/
public function doEnvironmentChecks() {
- $phpVersion = phpversion();
- if ( version_compare( $phpVersion, self::MINIMUM_PHP_VERSION, '>=' ) ) {
- $this->showMessage( 'config-env-php', $phpVersion );
- $good = true;
+ // Php version has already been checked by entry scripts
+ // Show message here for information purposes
+ if ( wfIsHHVM() ) {
+ $this->showMessage( 'config-env-hhvm', HHVM_VERSION );
} else {
- $this->showMessage( 'config-env-php-toolow', $phpVersion, self::MINIMUM_PHP_VERSION );
- $good = false;
+ $this->showMessage( 'config-env-php', PHP_VERSION );
}
+ $good = true;
// Must go here because an old version of PCRE can prevent other checks from completing
- if ( $good ) {
- list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
- if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
- $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
- $good = false;
- }
- }
-
- if ( $good ) {
+ list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
+ if ( version_compare( $pcreVersion, self::MINIMUM_PCRE_VERSION, '<' ) ) {
+ $this->showError( 'config-pcre-old', self::MINIMUM_PCRE_VERSION, $pcreVersion );
+ $good = false;
+ } else {
foreach ( $this->envChecks as $check ) {
$status = $this->$check();
if ( $status === false ) {
@@ -447,11 +460,17 @@ abstract class Installer {
return $good ? Status::newGood() : Status::newFatal( 'config-env-bad' );
}
+ public function doEnvironmentPreps() {
+ foreach ( $this->envPreps as $prep ) {
+ $this->$prep();
+ }
+ }
+
/**
* Set a MW configuration variable, or internal installer configuration variable.
*
- * @param $name String
- * @param $value Mixed
+ * @param string $name
+ * @param mixed $value
*/
public function setVar( $name, $value ) {
$this->settings[$name] = $value;
@@ -462,8 +481,8 @@ abstract class Installer {
* The defaults come from $GLOBALS (ultimately DefaultSettings.php).
* Installer variables are typically prefixed by an underscore.
*
- * @param $name String
- * @param $default Mixed
+ * @param string $name
+ * @param mixed $default
*
* @return mixed
*/
@@ -487,7 +506,7 @@ abstract class Installer {
/**
* Get an instance of DatabaseInstaller for the specified DB type.
*
- * @param $type Mixed: DB installer for which is needed, false to use default.
+ * @param mixed $type DB installer for which is needed, false to use default.
*
* @return DatabaseInstaller
*/
@@ -507,10 +526,9 @@ abstract class Installer {
}
/**
- * Determine if LocalSettings.php exists. If it does, return its variables,
- * merged with those from AdminSettings.php, as an array.
+ * Determine if LocalSettings.php exists. If it does, return its variables.
*
- * @return Array
+ * @return array
*/
public static function getExistingLocalSettings() {
global $IP;
@@ -521,6 +539,7 @@ abstract class Installer {
// registration out of the global scope and into a real format.
// @see https://bugzilla.wikimedia.org/67440
global $wgAutoloadClasses;
+ $wgAutoloadClasses = array();
wfSuppressWarnings();
$_lsExists = file_exists( "$IP/LocalSettings.php" );
@@ -533,9 +552,6 @@ abstract class Installer {
require "$IP/includes/DefaultSettings.php";
require "$IP/LocalSettings.php";
- if ( file_exists( "$IP/AdminSettings.php" ) ) {
- require "$IP/AdminSettings.php";
- }
return get_defined_vars();
}
@@ -545,7 +561,7 @@ abstract class Installer {
* This is a security mechanism to avoid compromise of the password in the
* event of session ID compromise.
*
- * @param $realPassword String
+ * @param string $realPassword
*
* @return string
*/
@@ -557,8 +573,8 @@ abstract class Installer {
* Set a variable which stores a password, except if the new value is a
* fake password in which case leave it as it is.
*
- * @param $name String
- * @param $value Mixed
+ * @param string $name
+ * @param mixed $value
*/
public function setPassword( $name, $value ) {
if ( !preg_match( '/^\*+$/', $value ) ) {
@@ -604,9 +620,9 @@ abstract class Installer {
* whatever, this function is guarded to catch the attempted DB access and to present
* some fallback text.
*
- * @param $text String
- * @param $lineStart Boolean
- * @return String
+ * @param string $text
+ * @param bool $lineStart
+ * @return string
*/
public function parse( $text, $lineStart = false ) {
global $wgParser;
@@ -645,7 +661,7 @@ abstract class Installer {
* Install step which adds a row to the site_stats table with appropriate
* initial values.
*
- * @param $installer DatabaseInstaller
+ * @param DatabaseInstaller $installer
*
* @return Status
*/
@@ -654,15 +670,19 @@ abstract class Installer {
if ( !$status->isOK() ) {
return $status;
}
- $status->value->insert( 'site_stats', array(
- 'ss_row_id' => 1,
- 'ss_total_views' => 0,
- 'ss_total_edits' => 0,
- 'ss_good_articles' => 0,
- 'ss_total_pages' => 0,
- 'ss_users' => 0,
- 'ss_images' => 0 ),
- __METHOD__, 'IGNORE' );
+ $status->value->insert(
+ 'site_stats',
+ array(
+ 'ss_row_id' => 1,
+ 'ss_total_views' => 0,
+ 'ss_total_edits' => 0,
+ 'ss_good_articles' => 0,
+ 'ss_total_pages' => 0,
+ 'ss_users' => 0,
+ 'ss_images' => 0
+ ),
+ __METHOD__, 'IGNORE'
+ );
return Status::newGood();
}
@@ -719,11 +739,16 @@ abstract class Installer {
/**
* Environment check for register_globals.
+ * Prevent installation if enabled
+ * @return bool
*/
protected function envCheckRegisterGlobals() {
if ( wfIniGetBool( 'register_globals' ) ) {
- $this->showMessage( 'config-register-globals' );
+ $this->showMessage( 'config-register-globals-error' );
+ return false;
}
+
+ return true;
}
/**
@@ -742,48 +767,19 @@ abstract class Installer {
}
/**
- * Test PHP (probably 5.3.1, but it could regress again) to make sure that
- * reference parameters to __call() are not converted to null
- * @return bool
- */
- protected function envCheckPHP531() {
- $test = new PhpRefCallBugTester;
- $test->execute();
- if ( !$test->ok ) {
- $this->showError( 'config-using531', phpversion() );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Environment check for magic_quotes_runtime.
+ * Environment check for magic_quotes_(gpc|runtime|sybase).
* @return bool
*/
protected function envCheckMagicQuotes() {
- if ( wfIniGetBool( "magic_quotes_runtime" ) ) {
- $this->showError( 'config-magic-quotes-runtime' );
-
- return false;
- }
-
- return true;
- }
-
- /**
- * Environment check for magic_quotes_sybase.
- * @return bool
- */
- protected function envCheckMagicSybase() {
- if ( wfIniGetBool( 'magic_quotes_sybase' ) ) {
- $this->showError( 'config-magic-quotes-sybase' );
-
- return false;
+ $status = true;
+ foreach ( array( 'gpc', 'runtime', 'sybase' ) as $magicJunk ) {
+ if ( wfIniGetBool( "magic_quotes_$magicJunk" ) ) {
+ $this->showError( "config-magic-quotes-$magicJunk" );
+ $status = false;
+ }
}
- return true;
+ return $status;
}
/**
@@ -801,20 +797,6 @@ abstract class Installer {
}
/**
- * Environment check for zend.ze1_compatibility_mode.
- * @return bool
- */
- protected function envCheckZE1() {
- if ( wfIniGetBool( 'zend.ze1_compatibility_mode' ) ) {
- $this->showError( 'config-ze1' );
-
- return false;
- }
-
- return true;
- }
-
- /**
* Environment check for safe_mode.
* @return bool
*/
@@ -995,55 +977,29 @@ abstract class Installer {
}
/**
- * Environment check for the server hostname.
+ * Environment check to inform user which server we've assumed.
+ *
+ * @return bool
*/
protected function envCheckServer() {
$server = $this->envGetDefaultServer();
if ( $server !== null ) {
$this->showMessage( 'config-using-server', $server );
- $this->setVar( 'wgServer', $server );
}
-
return true;
}
/**
- * Helper function to be called from envCheckServer()
- * @return String
- */
- abstract protected function envGetDefaultServer();
-
- /**
- * Environment check for setting $IP and $wgScriptPath.
+ * Environment check to inform user which paths we've assumed.
+ *
* @return bool
*/
protected function envCheckPath() {
- global $IP;
- $IP = dirname( dirname( __DIR__ ) );
- $this->setVar( 'IP', $IP );
-
$this->showMessage(
'config-using-uri',
$this->getVar( 'wgServer' ),
$this->getVar( 'wgScriptPath' )
);
-
- return true;
- }
-
- /**
- * Environment check for setting the preferred PHP file extension.
- * @return bool
- */
- protected function envCheckExtension() {
- // @todo FIXME: Detect this properly
- if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
- $ext = 'php5';
- } else {
- $ext = 'php';
- }
- $this->setVar( 'wgScriptExtension', ".$ext" );
-
return true;
}
@@ -1160,7 +1116,7 @@ abstract class Installer {
/**
* Convert a hex string representing a Unicode code point to that code point.
- * @param $c String
+ * @param string $c
* @return string
*/
protected function unicodeChar( $c ) {
@@ -1171,11 +1127,11 @@ abstract class Installer {
return chr( 0xC0 | $c >> 6 ) . chr( 0x80 | $c & 0x3F );
} elseif ( $c <= 0xFFFF ) {
return chr( 0xE0 | $c >> 12 ) . chr( 0x80 | $c >> 6 & 0x3F )
- . chr( 0x80 | $c & 0x3F );
+ . chr( 0x80 | $c & 0x3F );
} elseif ( $c <= 0x10FFFF ) {
return chr( 0xF0 | $c >> 18 ) . chr( 0x80 | $c >> 12 & 0x3F )
- . chr( 0x80 | $c >> 6 & 0x3F )
- . chr( 0x80 | $c & 0x3F );
+ . chr( 0x80 | $c >> 6 & 0x3F )
+ . chr( 0x80 | $c & 0x3F );
} else {
return false;
}
@@ -1248,6 +1204,19 @@ abstract class Installer {
/**
* @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' );
@@ -1259,11 +1228,49 @@ abstract class Installer {
}
/**
+ * Environment prep for the server hostname.
+ */
+ protected function envPrepServer() {
+ $server = $this->envGetDefaultServer();
+ if ( $server !== null ) {
+ $this->setVar( 'wgServer', $server );
+ }
+ }
+
+ /**
+ * Helper function to be called from envPrepServer()
+ * @return string
+ */
+ abstract protected function envGetDefaultServer();
+
+ /**
+ * Environment prep for setting the preferred PHP file extension.
+ */
+ protected function envPrepExtension() {
+ // @todo FIXME: Detect this properly
+ if ( defined( 'MW_INSTALL_PHP5_EXT' ) ) {
+ $ext = '.php5';
+ } else {
+ $ext = '.php';
+ }
+ $this->setVar( 'wgScriptExtension', $ext );
+ }
+
+ /**
+ * Environment prep for setting $IP and $wgScriptPath.
+ */
+ protected function envPrepPath() {
+ global $IP;
+ $IP = dirname( dirname( __DIR__ ) );
+ $this->setVar( 'IP', $IP );
+ }
+
+ /**
* Get an array of likely places we can find executables. Check a bunch
* of known Unix-like defaults, as well as the PATH environment variable
* (which should maybe make it work for Windows?)
*
- * @return Array
+ * @return array
*/
protected static function getPossibleBinPaths() {
return array_merge(
@@ -1280,11 +1287,11 @@ abstract class Installer {
*
* Used only by environment checks.
*
- * @param string $path path to search
- * @param array $names of executable names
- * @param $versionInfo Boolean false or array with two members:
- * 0 => Command to run for version check, with $1 for the full executable name
- * 1 => String to compare the output with
+ * @param string $path Path to search
+ * @param array $names Array of executable names
+ * @param array|bool $versionInfo False or array with two members:
+ * 0 => Command to run for version check, with $1 for the full executable name
+ * 1 => String to compare the output with
*
* If $versionInfo is not false, only executables with a version
* matching $versionInfo[1] will be returned.
@@ -1320,8 +1327,13 @@ abstract class Installer {
/**
* Same as locateExecutable(), but checks in getPossibleBinPaths() by default
* @see locateExecutable()
- * @param $names
- * @param $versionInfo bool
+ * @param array $names Array of possible names.
+ * @param array|bool $versionInfo Default: false or array with two members:
+ * 0 => Command to run for version check, with $1 for the full executable name
+ * 1 => String to compare the output with
+ *
+ * If $versionInfo is not false, only executables with a version
+ * matching $versionInfo[1] will be returned.
* @return bool|string
*/
public static function locateExecutableInDefaultPaths( $names, $versionInfo = false ) {
@@ -1339,8 +1351,8 @@ abstract class Installer {
* Checks if scripts located in the given directory can be executed via the given URL.
*
* Used only by environment checks.
- * @param $dir string
- * @param $url string
+ * @param string $dir
+ * @param string $url
* @return bool|int|string
*/
public function dirIsExecutable( $dir, $url ) {
@@ -1405,7 +1417,7 @@ abstract class Installer {
/**
* ParserOptions are constructed before we determined the language, so fix it
*
- * @param $lang Language
+ * @param Language $lang
*/
public function setParserLanguage( $lang ) {
$this->parserOptions->setTargetLanguage( $lang );
@@ -1414,7 +1426,7 @@ abstract class Installer {
/**
* Overridden by WebInstaller to provide lastPage parameters.
- * @param $page string
+ * @param string $page
* @return string
*/
protected function getDocUrl( $page ) {
@@ -1422,35 +1434,20 @@ abstract class Installer {
}
/**
- * Load the extension credits for i18n strings. Very hacky for
- * now, but I expect it only be used for 1.22.0 at the most.
- */
- public function getExtensionInfo( $file ) {
- global $wgExtensionCredits, $wgVersion, $wgResourceModules;
-
- $wgVersion = "1.22";
- $wgResourceModules = array();
- require_once $file ;
- $e = array_values( $wgExtensionCredits );
- if( $e ) {
- $ext = array_values( $e[0] );
- $wgExtensionCredits = array();
- return $ext[0];
- }
- }
-
- /**
- * Finds extensions that follow the format /extensions/Name/Name.php,
+ * Finds extensions that follow the format /$directory/Name/Name.php,
* and returns an array containing the value for 'Name' for each found extension.
*
+ * Reasonable values for $directory include 'extensions' (the default) and 'skins'.
+ *
+ * @param string $directory Directory to search in
* @return array
*/
- public function findExtensions() {
+ public function findExtensions( $directory = 'extensions' ) {
if ( $this->getVar( 'IP' ) === null ) {
return array();
}
- $extDir = $this->getVar( 'IP' ) . '/extensions';
+ $extDir = $this->getVar( 'IP' ) . '/' . $directory;
if ( !is_readable( $extDir ) || !is_dir( $extDir ) ) {
return array();
}
@@ -1461,26 +1458,33 @@ abstract class Installer {
if ( !is_dir( "$extDir/$file" ) ) {
continue;
}
-
- $extFile = "$extDir/$file/$file.php";
- $extI18NFile = "$extDir/$file/$file.i18n.php";
- if ( file_exists( $extFile ) ) {
- if ( $info = $this->getExtensionInfo( $extFile ) ) {
- $exts[$info['name']] = $info;
-
- if ( file_exists( $extI18NFile ) ) {
- global $wgExtensionMessagesFiles;
- $wgExtensionMessagesFiles[$file] = $extI18NFile;
- }
- }
+ if ( file_exists( "$extDir/$file/$file.php" ) ) {
+ $exts[] = $file;
}
}
closedir( $dh );
- uksort( $exts, 'strnatcasecmp' );
+ natcasesort( $exts );
+
return $exts;
}
/**
+ * Returns a default value to be used for $wgDefaultSkin: the preferred skin, if available among
+ * the installed skins, or any other one otherwise.
+ *
+ * @param string[] $skinNames Names of installed skins.
+ * @return string
+ */
+ public function getDefaultSkin( array $skinNames ) {
+ $defaultSkin = $GLOBALS['wgDefaultSkin'];
+ if ( in_array( $defaultSkin, $skinNames ) ) {
+ return $defaultSkin;
+ } else {
+ return $skinNames[0];
+ }
+ }
+
+ /**
* Installs the auto-detected extensions.
*
* @return Status
@@ -1503,9 +1507,8 @@ abstract class Installer {
require "$IP/includes/DefaultSettings.php";
- $extensions = $this->findExtensions();
foreach ( $exts as $e ) {
- require_once $extensions[$e]['path'];
+ require_once "$IP/extensions/$e/$e.php";
}
$hooksWeWant = isset( $wgHooks['LoadExtensionSchemaUpdates'] ) ?
@@ -1527,7 +1530,7 @@ abstract class Installer {
* There must be a config-install-$name message defined per step, which will
* be shown on install.
*
- * @param $installer DatabaseInstaller so we can make callbacks
+ * @param DatabaseInstaller $installer DatabaseInstaller so we can make callbacks
* @return array
*/
protected function getInstallSteps( DatabaseInstaller $installer ) {
@@ -1537,6 +1540,7 @@ abstract class Installer {
array( 'name' => 'interwiki', 'callback' => array( $installer, 'populateInterwikiTable' ) ),
array( 'name' => 'stats', 'callback' => array( $this, 'populateSiteStats' ) ),
array( 'name' => 'keys', 'callback' => array( $this, 'generateKeys' ) ),
+ array( 'name' => 'updates', 'callback' => array( $installer, 'insertUpdateKeys' ) ),
array( 'name' => 'sysop', 'callback' => array( $this, 'createSysop' ) ),
array( 'name' => 'mainpage', 'callback' => array( $this, 'createMainpage' ) ),
);
@@ -1578,10 +1582,10 @@ abstract class Installer {
/**
* Actually perform the installation.
*
- * @param array $startCB A callback array for the beginning of each step
- * @param array $endCB A callback array for the end of each step
+ * @param callable $startCB A callback array for the beginning of each step
+ * @param callable $endCB A callback array for the end of each step
*
- * @return Array of Status objects
+ * @return array Array of Status objects
*/
public function performInstallation( $startCB, $endCB ) {
$installResults = array();
@@ -1630,7 +1634,7 @@ abstract class Installer {
* Generate a secret value for variables using our CryptRand generator.
* Produce a warning if the random source was insecure.
*
- * @param $keys Array
+ * @param array $keys
* @return Status
*/
protected function doGenerateKeys( $keys ) {
@@ -1700,7 +1704,7 @@ abstract class Installer {
}
/**
- * @param $s Status
+ * @param Status $s
*/
private function subscribeToMediaWikiAnnounce( Status $s ) {
$params = array(
@@ -1731,7 +1735,7 @@ abstract class Installer {
/**
* Insert Main Page with default content.
*
- * @param $installer DatabaseInstaller
+ * @param DatabaseInstaller $installer
* @return Status
*/
protected function createMainpage( DatabaseInstaller $installer ) {
@@ -1784,19 +1788,14 @@ abstract class Installer {
// Some of the environment checks make shell requests, remove limits
$GLOBALS['wgMaxShellMemory'] = 0;
-
- // Don't bother embedding images into generated CSS, which is not cached
- $GLOBALS['wgResourceLoaderLESSFunctions']['embeddable'] = function( $frame, $less ) {
- return $less->toBool( false );
- };
}
/**
* Add an installation step following the given step.
*
- * @param array $callback A valid installation callback array, in this form:
+ * @param callable $callback A valid installation callback array, in this form:
* array( 'name' => 'some-unique-name', 'callback' => array( $obj, 'function' ) );
- * @param string $findStep the step to find. Omit to put the step at the beginning
+ * @param string $findStep The step to find. Omit to put the step at the beginning
*/
public function addInstallStep( $callback, $findStep = 'BEGINNING' ) {
$this->extraInstallSteps[$findStep][] = $callback;