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