r13880 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13879‎ | r13880 | r13881 >
Date:20:42, 26 April 2006
Author:robchurch
Status:old
Tags:
Comment:
Improvements to update scripts; print out the version, check for superuser credentials before attempting a connection, and produce a friendlier error if the connection fails
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/maintenance/update.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/update.php
@@ -14,14 +14,37 @@
1515 require_once( "commandLine.inc" );
1616 require_once( "updaters.inc" );
1717 $wgTitle = Title::newFromText( "MediaWiki database updater" );
18 -$dbclass = 'Database'.ucfirst($wgDBtype);
 18+$dbclass = 'Database' . ucfirst( $wgDBtype ) ;
1919 require_once("$dbclass.php");
2020 $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 );
2521
 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+
2649 print "Going to run database updates for $wgDBname\n";
2750 print "Depending on the size of your database this may take a while!\n";
2851
Index: trunk/phase3/RELEASE-NOTES
@@ -127,6 +127,8 @@
128128 * Pass login link to "whitelistedittext" containing 'returnto' parameter
129129 * (bug 5728): mVersion missing from User::__sleep() leading to constant cache miss
130130 * 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
131133
132134 == Compatibility ==
133135

Status & tagging log