X-Git-Url: https://git.cyclocoop.org/%27.WWW_URL.%27admin/?a=blobdiff_plain;ds=sidebyside;f=maintenance%2Fupdate.php;h=5809e60318be07938a4b178c8aec998863c8aadd;hb=9ac33a362f9a8f461906454b3d9abf0aed165ac7;hp=d2dcbf92bbed3770af50c126c7533a4d4e52fa19;hpb=e174a4ddfb96feee0a8305c60aade97c0ee30d3c;p=lhc%2Fweb%2Fwiklou.git diff --git a/maintenance/update.php b/maintenance/update.php index d2dcbf92bb..5809e60318 100644 --- a/maintenance/update.php +++ b/maintenance/update.php @@ -1,65 +1,95 @@ isOpen() ) { - # Appears to have failed - echo( "A connection to the database could not be established. Check the\n" ); - echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" ); - exit(); -} + public function __construct() { + parent::__construct(); + $this->mDescription = "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' ); + $this->addOption( 'nopurge', 'Do not purge the objectcache table after updates' ); + } -print "Going to run database updates for ".wfWikiID()."\n"; -print "Depending on the size of your database this may take a while!\n"; + public function getDbType() { + return self::DB_ADMIN; + } -if( !isset( $options['quick'] ) ) { - print "Abort with control-c in the next five seconds... "; + public function execute() { + global $wgVersion, $wgTitle; - for ($i = 6; $i >= 1;) { - print_c($i, --$i); - sleep(1); - } - echo "\n"; -} + $wgTitle = Title::newFromText( "MediaWiki database updater" ); -if ( isset( $options['doshared'] ) ) { - $doShared = true; -} else { - $doShared = false; -} + $this->output( "MediaWiki {$wgVersion} Updater\n\n" ); + + if ( !isset( $options['skip-compat-checks'] ) ) { + install_version_checks(); + } else { + $this->output( "Skipping compatibility checks, proceed at your own risk (Ctrl+C to abort)\n" ); + wfCountdown( 5 ); + } + + # 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 ); + + $this->output( "Going to run database updates for " . wfWikiID() . "\n" ); + $this->output( "Depending on the size of your database this may take a while!\n" ); -do_all_updates( $doShared ); + if ( !$this->hasOption( 'quick' ) ) { + $this->output( "Abort with control-c in the next five seconds (skip this countdown with --quick) ... " ); + wfCountDown( 5 ); + } -print "Done.\n"; + $shared = $this->hasOption( 'doshared' ); + $purge = !$this->hasOption( 'nopurge' ); + + $updater = DatabaseUpdater::newForDb( $db, $shared ); + $updater->doUpdates( $purge ); + + if ( !defined( 'MW_NO_SETUP' ) ) { + define( 'MW_NO_SETUP', true ); + } + + foreach( $updater->getPostDatabaseUpdateMaintenance() as $maint ) { + call_user_func_array( array( new $maint, 'execute' ), array() ); + } + + if ( $db->getType() === 'postgres' ) { + return; + } + + do_stats_init(); + + $this->output( "Done.\n" ); + } + + protected function afterFinalSetup() { + global $wgLocalisationCacheConf; + + # Don't try to access the database + # This needs to be disabled early since extensions will try to use the l10n + # cache from $wgExtensionSetupFunctions (bug 20471) + $wgLocalisationCacheConf = array( + 'class' => 'LocalisationCache', + 'storeClass' => 'LCStore_Null', + 'storeDirectory' => false, + 'manualRecache' => false, + ); + } +} -?> +$maintClass = 'UpdateMediaWiki'; +require_once( DO_MAINTENANCE );