Fixed issues in r72940 - missing $ in release notes and remnant of ResourceLoaderUser...
[lhc/web/wiklou.git] / maintenance / update.php
1 <?php
2 /**
3 * Run all updaters.
4 *
5 * This is used when the database schema is modified and we need to apply patches.
6 *
7 * @file
8 * @todo document
9 * @ingroup Maintenance
10 */
11
12 $wgUseMasterForMaintenance = true;
13 require_once( 'Maintenance.php' );
14
15 class UpdateMediaWiki extends Maintenance {
16
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' );
24 }
25
26 public function getDbType() {
27 return Maintenance::DB_ADMIN;
28 }
29
30 public function execute() {
31 global $wgVersion, $wgTitle, $wgLang;
32
33 $wgLang = Language::factory( 'en' );
34 $wgTitle = Title::newFromText( "MediaWiki database updater" );
35
36 $this->output( "MediaWiki {$wgVersion} Updater\n\n" );
37
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 );
43 }
44
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 );
48
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" );
51
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 );
55 }
56
57 $shared = $this->hasOption( 'doshared' );
58 $purge = !$this->hasOption( 'nopurge' );
59
60 $updater = DatabaseUpdater::newForDb( $db, $shared );
61 $updater->doUpdates( $purge );
62
63 foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
64 $this->runChild( $maint )->execute();
65 }
66
67 $this->output( "\nDone.\n" );
68 }
69
70 protected function afterFinalSetup() {
71 global $wgLocalisationCacheConf;
72
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 $wgExtensionSetupFunctions (bug 20471)
76 $wgLocalisationCacheConf = array(
77 'class' => 'LocalisationCache',
78 'storeClass' => 'LCStore_Null',
79 'storeDirectory' => false,
80 'manualRecache' => false,
81 );
82 }
83 }
84
85 $maintClass = 'UpdateMediaWiki';
86 require_once( DO_MAINTENANCE );