r13881 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r13880‎ | r13881 | r13882 >
Date:20:54, 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:
  • /branches/REL1_6/phase3/RELEASE-NOTES (modified) (history)
  • /branches/REL1_6/phase3/maintenance/update.php (modified) (history)

Diff [purge]

Index: branches/REL1_6/phase3/maintenance/update.php
@@ -14,11 +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 -$wgDatabase = $dbc->newFromParams( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname );
2221
 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+
2349 print "Going to run database updates for $wgDBname\n";
2450 print "Depending on the size of your database this may take a while!\n";
2551
Index: branches/REL1_6/phase3/RELEASE-NOTES
@@ -34,8 +34,9 @@
3535 * (bug 5497) regeression in HTML normalization in 1.6 (unclosed <li>,<dd>,<dt>)
3636 * (bug 5709) Allow customisation of separator for categories
3737 * (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
3840
39 -
4041 == MediaWiki 1.6.3 ==
4142
4243 April 10, 2006

Status & tagging log