Per Nikerabbit, follow-up to r74191: tag for removal in 1.19; I removed the last...
[mediawiki.git] / maintenance / update.php
blob8115e7a6b48fa4be1758dd22ff1e91fcc4f9ade7
1 <?php
2 /**
3 * Run all updaters.
5 * This is used when the database schema is modified and we need to apply patches.
7 * @file
8 * @todo document
9 * @ingroup Maintenance
12 $wgUseMasterForMaintenance = true;
13 require_once( 'Maintenance.php' );
15 class UpdateMediaWiki extends Maintenance {
17 public function __construct() {
18 parent::__construct();
19 $this->mDescription = "MediaWiki database updater";
20 $this->addOption( 'skip-compat-checks', 'Skips compatibility checks, mostly for developers' );
21 $this->addOption( 'quick', 'Skip 5 second countdown before starting' );
22 $this->addOption( 'doshared', 'Also update shared tables' );
23 $this->addOption( 'nopurge', 'Do not purge the objectcache table after updates' );
26 public function getDbType() {
27 return Maintenance::DB_ADMIN;
30 public function execute() {
31 global $wgVersion, $wgTitle, $wgLang;
33 $wgLang = Language::factory( 'en' );
34 $wgTitle = Title::newFromText( "MediaWiki database updater" );
36 $this->output( "MediaWiki {$wgVersion} Updater\n\n" );
38 if ( !$this->hasOption( 'skip-compat-checks' ) ) {
39 install_version_checks();
40 } else {
41 $this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
42 wfCountdown( 5 );
45 # Attempt to connect to the database as a privileged user
46 # This will vomit up an error if there are permissions problems
47 $db = wfGetDB( DB_MASTER );
49 $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
50 $this->output( "Depending on the size of your database this may take a while!\n" );
52 if ( !$this->hasOption( 'quick' ) ) {
53 $this->output( "Abort with control-c in the next five seconds (skip this countdown with --quick) ... " );
54 wfCountDown( 5 );
57 $shared = $this->hasOption( 'doshared' );
58 $purge = !$this->hasOption( 'nopurge' );
60 $updater = DatabaseUpdater::newForDb( $db, $shared );
61 $updater->doUpdates( $purge );
63 foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
64 $this->runChild( $maint )->execute();
67 $this->output( "\nDone.\n" );
70 protected function afterFinalSetup() {
71 global $wgLocalisationCacheConf;
73 # Don't try to access the database
74 # This needs to be disabled early since extensions will try to use the l10n
75 # cache from $wgExtensionFunctions (bug 20471)
76 $wgLocalisationCacheConf = array(
77 'class' => 'LocalisationCache',
78 'storeClass' => 'LCStore_Null',
79 'storeDirectory' => false,
80 'manualRecache' => false,
85 $maintClass = 'UpdateMediaWiki';
86 require_once( DO_MAINTENANCE );