5 * This is used when the database schema is modified and we need to apply patches.
6 * It is kept compatible with php 4 parsing so that it can give out a meaningful error.
10 * @ingroup Maintenance
13 if ( !function_exists( 'version_compare' ) ||
( version_compare( phpversion(), '5.1.0' ) < 0 ) ) {
14 echo "You are using PHP version " . phpversion() . " but MediaWiki needs PHP 5.1.0 or higher. ABORTING.\n" .
15 "Check if you have a newer php executable with a different name, such as php5.\n";
19 $wgUseMasterForMaintenance = true;
20 require_once( dirname( __FILE__
) . '/Maintenance.php' );
22 class UpdateMediaWiki
extends Maintenance
{
24 function __construct() {
25 parent
::__construct();
26 $this->mDescription
= "MediaWiki database updater";
27 $this->addOption( 'skip-compat-checks', 'Skips compatibility checks, mostly for developers' );
28 $this->addOption( 'quick', 'Skip 5 second countdown before starting' );
29 $this->addOption( 'doshared', 'Also update shared tables' );
30 $this->addOption( 'nopurge', 'Do not purge the objectcache table after updates' );
33 function getDbType() {
34 return 2 /* Maintenance::DB_ADMIN */;
38 global $wgVersion, $wgTitle, $wgLang;
40 $wgLang = Language
::factory( 'en' );
41 $wgTitle = Title
::newFromText( "MediaWiki database updater" );
43 $this->output( "MediaWiki {$wgVersion} Updater\n\n" );
45 if ( !$this->hasOption( 'skip-compat-checks' ) ) {
46 install_version_checks();
48 $this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" );
52 # Attempt to connect to the database as a privileged user
53 # This will vomit up an error if there are permissions problems
54 $db = wfGetDB( DB_MASTER
);
56 $this->output( "Going to run database updates for " . wfWikiID() . "\n" );
57 $this->output( "Depending on the size of your database this may take a while!\n" );
59 if ( !$this->hasOption( 'quick' ) ) {
60 $this->output( "Abort with control-c in the next five seconds (skip this countdown with --quick) ... " );
64 $shared = $this->hasOption( 'doshared' );
65 $purge = !$this->hasOption( 'nopurge' );
67 $updater = DatabaseUpdater
::newForDb( $db, $shared, $this );
68 $updater->doUpdates( $purge );
70 foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) {
71 $child = $this->runChild( $maint );
75 $this->output( "\nDone.\n" );
78 function afterFinalSetup() {
79 global $wgLocalisationCacheConf;
81 # Don't try to access the database
82 # This needs to be disabled early since extensions will try to use the l10n
83 # cache from $wgExtensionFunctions (bug 20471)
84 $wgLocalisationCacheConf = array(
85 'class' => 'LocalisationCache',
86 'storeClass' => 'LCStore_Null',
87 'storeDirectory' => false,
88 'manualRecache' => false,
93 $maintClass = 'UpdateMediaWiki';
94 require_once( DO_MAINTENANCE
);