Added check for valid user permissions when updating database
authorTim Starling <tstarling@users.mediawiki.org>
Sun, 26 Sep 2004 10:07:31 +0000 (10:07 +0000)
committerTim Starling <tstarling@users.mediawiki.org>
Sun, 26 Sep 2004 10:07:31 +0000 (10:07 +0000)
config/index.php

index 9ce8c17..25c511d 100644 (file)
@@ -461,11 +461,24 @@ if( $conf->posted && ( 0 == count( $errs ) ) ) {
                $wgDatabase->selectDB( $wgDBname );
 
                if( $wgDatabase->tableExists( "cur" ) ) {
-                       print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n<pre>";
-
+                       print "<li>There are already MediaWiki tables in this database. Checking if updates are needed...</li>\n";
+                       
+                       # Create user if required
+                       if ( $conf->Root ) {
+                               $conn = Database::newFromParams( $wgDBserver, $wgDBuser, $wgDBpassword, $wgDBname, 1 );
+                               if ( $conn->isOpen() ) {
+                                       print "<li>DB user account ok</li>\n";
+                                       $conn->close();
+                               } else {
+                                       print "<li>Granting user permissions...</li>\n";
+                                       dbsource( "../maintenance/users.sql", $wgDatabase );
+                               }
+                       }
+                       print "<pre>\n";
                        chdir( ".." );
                        flush();
 
+
                        # Add missing tables
                        foreach ( $wgNewTables as $tableRecord ) {
                                add_table( $tableRecord[0], $tableRecord[1] );