Index: branches/REL1_6/phase3/maintenance/update.php |
— | — | @@ -14,11 +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 | | -$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname ); |
22 | 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 | + |
23 | 49 | print "Going to run database updates for $wgDBname\n"; |
24 | 50 | print "Depending on the size of your database this may take a while!\n"; |
25 | 51 | |
Index: branches/REL1_6/phase3/RELEASE-NOTES |
— | — | @@ -34,8 +34,9 @@ |
35 | 35 | * (bug 5497) regeression in HTML normalization in 1.6 (unclosed <li>,<dd>,<dt>) |
36 | 36 | * (bug 5709) Allow customisation of separator for categories |
37 | 37 | * (bug 4834) Fix XHTML output when using $wgMaxTocLevel |
| 38 | +* Improvements to update scripts; print out the version, check for superuser credentials |
| 39 | + before attempting a connection, and produce a friendlier error if the connection fails |
38 | 40 | |
39 | | - |
40 | 41 | == MediaWiki 1.6.3 == |
41 | 42 | |
42 | 43 | April 10, 2006 |