* Run all updaters.
*
* This is used when the database schema is modified and we need to apply patches.
- * It is kept compatible with php 4 parsing so that it can give out a meaningful error.
*
* 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
class UpdateMediaWiki extends Maintenance {
function __construct() {
parent::__construct();
- $this->mDescription = "MediaWiki database updater";
+ $this->addDescription( 'MediaWiki database updater' );
$this->addOption( 'skip-compat-checks', 'Skips compatibility checks, mostly for developers' );
$this->addOption( 'quick', 'Skip 5 second countdown before starting' );
$this->addOption( 'doshared', 'Also update shared tables' );
}
function compatChecks() {
- // Avoid syntax error in PHP4
- $minimumPcreVersion = constant( 'Installer::MINIMUM_PCRE_VERSION' );
+ $minimumPcreVersion = Installer::MINIMUM_PCRE_VERSION;
list( $pcreVersion ) = explode( ' ', PCRE_VERSION, 2 );
if ( version_compare( $pcreVersion, $minimumPcreVersion, '<' ) ) {
}
}
- $wgLang = Language::factory( 'en' );
+ $lang = Language::factory( 'en' );
+ // Set global language to ensure localised errors are in English (bug 20633)
+ RequestContext::getMain()->setLanguage( $lang );
+ $wgLang = $lang; // BackCompat
define( 'MW_UPDATER', true );
# Attempt to connect to the database as a privileged user
# This will vomit up an error if there are permissions problems
- $db = wfGetDB( DB_MASTER );
+ $db = $this->getDB( DB_MASTER );
$this->output( "Going to run database updates for " . wfWikiID() . "\n" );
if ( $db->getType() === 'sqlite' ) {
$shared = $this->hasOption( 'doshared' );
- $updates = array( 'core', 'extensions' );
+ $updates = [ 'core', 'extensions' ];
if ( !$this->hasOption( 'schema' ) ) {
if ( $this->hasOption( 'noschema' ) ) {
$updates[] = 'noschema';
$child = $this->runChild( $maint );
// LoggedUpdateMaintenance is checking the updatelog itself
- $isLoggedUpdate = is_a( $child, 'LoggedUpdateMaintenance' );
+ $isLoggedUpdate = $child instanceof LoggedUpdateMaintenance;
if ( !$isLoggedUpdate && $updater->updateRowExists( $maint ) ) {
continue;
$time2 = microtime( true );
- $timeDiff = $wgLang->formatTimePeriod( $time2 - $time1 );
+ $timeDiff = $lang->formatTimePeriod( $time2 - $time1 );
$this->output( "\nDone in $timeDiff.\n" );
}
# Don't try to access the database
# This needs to be disabled early since extensions will try to use the l10n
# cache from $wgExtensionFunctions (bug 20471)
- $wgLocalisationCacheConf = array(
+ $wgLocalisationCacheConf = [
'class' => 'LocalisationCache',
'storeClass' => 'LCStoreNull',
'storeDirectory' => false,
'manualRecache' => false,
- );
+ ];
}
}