Index: trunk/phase3/maintenance/update.php |
— | — | @@ -14,14 +14,37 @@ |
15 | 15 | require_once( "commandLine.inc" ); |
16 | 16 | require_once( "updaters.inc" ); |
17 | 17 | $wgTitle = Title::newFromText( "MediaWiki database updater" ); |
18 | | -$dbclass = 'Database'.ucfirst($wgDBtype); |
| 18 | +$dbclass = 'Database' . ucfirst( $wgDBtype ) ; |
19 | 19 | require_once("$dbclass.php"); |
20 | 20 | $dbc = new $dbclass; |
21 | | -# TODO : check for AdminSettings file existence ? See #5725 |
22 | | -print "Attempting connection to the database. If it fails, maybe you are\n"; |
23 | | -print "missing a proper AdminSettings.php file in $IP\n\n"; |
24 | | -$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
25 | 21 | |
| 22 | +echo( "MediaWiki {$wgVersion} Updater\n\n" ); |
| 23 | + |
| 24 | +# Do a pre-emptive check to ensure we've got credentials supplied |
| 25 | +# We can't, at this stage, check them, but we can detect their absence, |
| 26 | +# which seems to cause most of the problems people whinge about |
| 27 | +if( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) { |
| 28 | + echo( "No superuser credentials could be found. Please provide the details\n" ); |
| 29 | + echo( "of a user with appropriate permissions to update the database. See\n" ); |
| 30 | + echo( "AdminSettings.sample for more details.\n\n" ); |
| 31 | + exit(); |
| 32 | +} |
| 33 | + |
| 34 | +# Attempt to connect to the database as a privileged user |
| 35 | +# This will vomit up an error if there are permissions problems |
| 36 | +$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 ); |
| 37 | + |
| 38 | +if( !$wgDatabase->isOpen() ) { |
| 39 | + # Appears to have failed |
| 40 | + echo( "A connection to the database could not be established. Check the\n" ); |
| 41 | + # Let's be a bit clever and guess at what's wrong |
| 42 | + if( isset( $wgDBadminuser ) && isset( $wgDBadminpassword ) ) { |
| 43 | + # Tell the user the value(s) are wrong |
| 44 | + echo( 'values of $wgDBadminuser and $wgDBadminpassword.' . "\n" ); |
| 45 | + } |
| 46 | + exit(); |
| 47 | +} |
| 48 | + |
26 | 49 | print "Going to run database updates for $wgDBname\n"; |
27 | 50 | print "Depending on the size of your database this may take a while!\n"; |
28 | 51 | |
Index: trunk/phase3/RELEASE-NOTES |
— | — | @@ -127,6 +127,8 @@ |
128 | 128 | * Pass login link to "whitelistedittext" containing 'returnto' parameter |
129 | 129 | * (bug 5728): mVersion missing from User::__sleep() leading to constant cache miss |
130 | 130 | * Updated maintenance/transstat.php so it can show duplicate messages |
| 131 | +* Improvements to update scripts; print out the version, check for superuser credentials |
| 132 | + before attempting a connection, and produce a friendlier error if the connection fails |
131 | 133 | |
132 | 134 | == Compatibility == |
133 | 135 | |