r75305 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75304‎ | r75305 | r75306 >
Date:10:49, 24 October 2010
Author:ialex
Status:deferred
Tags:
Comment:
* Much simplier to use wfGetDB( DB_MASTER ) to get a db connection with admin rights...
* Use full path to commandLine.inc
Modified paths:
  • /trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php (modified) (history)

Diff [purge]

Index: trunk/extensions/StarterWiki/maintenance/createWikiDBFromStarter.php
@@ -26,31 +26,9 @@
2727
2828 $optionsWithArgs = array( 'database' );
2929 $wgUseMasterForMaintenance = true;
30 -require_once( "commandLine.inc" );
 30+require_once( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) . '/maintenance/commandLine.inc' );
3131 $wgTitle = Title::newFromText( "StarterWiki Database Creator" );
32 -$dbclass = 'Database' . ucfirst( $wgDBtype );
3332
34 -# Do a pre-emptive check to ensure we've got credentials supplied
35 -# We can't, at this stage, check them, but we can detect their absence,
36 -# which seems to cause most of the problems people whinge about
37 -if ( !isset( $wgDBadminuser ) || !isset( $wgDBadminpassword ) ) {
38 - echo( "No superuser credentials could be found. Please provide the details\n" );
39 - echo( "of a user with appropriate permissions to update the database. See\n" );
40 - echo( "AdminSettings.sample for more details.\n\n" );
41 - exit();
42 -}
43 -
44 -# Attempt to connect to the database as a privileged user
45 -# This will vomit up an error if there are permissions problems
46 -$wgDatabase = new $dbclass( $wgDBserver, $wgDBadminuser, $wgDBadminpassword, $wgDBname, 1 );
47 -
48 -if ( !isset( $wgDatabase ) || !$wgDatabase->isOpen() ) {
49 - # Appears to have failed
50 - echo( "A connection to the database could not be established. Check the\n" );
51 - echo( "values of \$wgDBadminuser and \$wgDBadminpassword.\n" );
52 - exit();
53 -}
54 -
5533 function usageInfo() {
5634 echo <<<TEXT
5735 Usage:
@@ -207,4 +185,4 @@
208186 return true;
209187 }
210188
211 -tryRunCreate( $wgDatabase );
 189+tryRunCreate( wfGetDB( DB_MASTER ) );

Status & tagging log