]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - maintenance/update.php
MediaWiki 1.14.0-scripts
[autoinstallsdev/mediawiki.git] / maintenance / update.php
1 <?php
2 require_once 'counter.php';
3 /**
4  * Run all updaters.
5  *
6  * This is used when the database schema is modified and we need to apply patches.
7  *
8  * @file
9  * @todo document
10  * @ingroup Maintenance
11  */
12
13 /** */
14 $wgUseMasterForMaintenance = true;
15 $options = array( 'quick', 'nopurge' );
16 require_once( "commandLine.inc" );
17 require_once( "updaters.inc" );
18 $wgTitle = Title::newFromText( "MediaWiki database updater" );
19 $dbclass = 'Database' . ucfirst( $wgDBtype ) ;
20
21 echo( "MediaWiki {$wgVersion} Updater\n\n" );
22
23 install_version_checks();
24
25 # Do a pre-emptive check to ensure we've got credentials supplied
26 # We can't, at this stage, check them, but we can detect their absence,
27 # which seems to cause most of the problems people whinge about
28 if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
29         echo( "No superuser credentials could be found. Please provide the details\n" );
30         echo( "of a user with appropriate permissions to update the database. See\n" );
31         echo( "AdminSettings.sample for more details.\n\n" );
32         exit();
33 }
34
35 # Attempt to connect to the database as a privileged user
36 # This will vomit up an error if there are permissions problems
37 $wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
38
39 if( !$wgDatabase->isOpen() ) {
40         # Appears to have failed
41         echo( "A connection to the database could not be established. Check the\n" );
42         echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" );
43         exit();
44 }
45
46 print "Going to run database updates for ".wfWikiID()."\n";
47 print "Depending on the size of your database this may take a while!\n";
48
49 if( !isset( $options['quick'] ) ) {
50         print "Abort with control-c in the next five seconds... ";
51
52         for ($i = 6; $i >= 1;) {
53                 print_c($i, --$i);
54                 sleep(1);
55         }
56         echo "\n";
57 }
58
59 $shared = isset( $options['doshared'] );
60 $purge = !isset( $options['nopurge'] );
61
62 do_all_updates( $shared, $purge );
63
64 print "Done.\n";
65
66