Revert to r15092; massive breakage, unable to connect to MySQL at all
[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 require_once("$dbclass.php");
19 $dbc = new $dbclass;
20
21 echo( "MediaWiki {$wgVersion} Updater\n\n" );
22
23 # Do a pre-emptive check to ensure we've got credentials supplied
24 # We can't, at this stage, check them, but we can detect their absence,
25 # which seems to cause most of the problems people whinge about
26 if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
27 echo( "No superuser credentials could be found. Please provide the details\n" );
28 echo( "of a user with appropriate permissions to update the database. See\n" );
29 echo( "AdminSettings.sample for more details.\n\n" );
30 exit();
31 }
32
33 # Attempt to connect to the database as a privileged user
34 # This will vomit up an error if there are permissions problems
35 $wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
36
37 if( !$wgDatabase->isOpen() ) {
38 # Appears to have failed
39 echo( "A connection to the database could not be established. Check the\n" );
40 # Let's be a bit clever and guess at what's wrong
41 if( isset( $wgDBadminuser ) && isset( $wgDBadminpassword ) ) {
42 # Tell the user the value(s) are wrong
43 echo( 'values of $wgDBadminuser and $wgDBadminpassword.' . "\n" );
44 }
45 exit();
46 }
47
48 print "Going to run database updates for $wgDBname\n";
49 print "Depending on the size of your database this may take a while!\n";
50
51 if( !isset( $options['quick'] ) ) {
52 print "Abort with control-c in the next five seconds... ";
53
54 for ($i = 6; $i >= 1;) {
55 print_c($i, --$i);
56 sleep(1);
57 }
58 echo "\n";
59 }
60
61 if ( isset( $options['doshared'] ) ) {
62 $doShared = true;
63 } else {
64 $doShared = false;
65 }
66
67 do_all_updates( $doShared );
68
69 print "Done.\n";
70
71 ?>