(bug 28375) When using existing DB user, grants aren't added to new tables
authorChad Horohoe <demon@users.mediawiki.org>
Mon, 2 May 2011 18:54:31 +0000 (18:54 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Mon, 2 May 2011 18:54:31 +0000 (18:54 +0000)
includes/installer/MysqlInstaller.php

index 7ef8ddf..467f0e7 100644 (file)
@@ -419,10 +419,6 @@ class MysqlInstaller extends DatabaseInstaller {
        }
 
        public function setupUser() {
-               if ( !$this->getVar( '_CreateDBAccount' ) ) {
-                       return Status::newGood();
-               }
-
                $status = $this->getConnection();
                if ( !$status->isOK() ) {
                        return $status;
@@ -436,21 +432,26 @@ class MysqlInstaller extends DatabaseInstaller {
                $password = $this->getVar( 'wgDBpassword' );
                $grantableNames = array();
 
-               // Before we blindly try to create a user that already has access,
-               try { // first attempt to connect to the database
-                       new DatabaseMysql(
-                               $server,
-                               $dbUser,
-                               $password,
-                               false,
-                               false,
-                               0,
-                               $this->getVar( 'wgDBprefix' )
-                       );
+               if ( $this->getVar( '_CreateDBAccount' ) ) {
+                       // Before we blindly try to create a user that already has access,
+                       try { // first attempt to connect to the database
+                               new DatabaseMysql(
+                                       $server,
+                                       $dbUser,
+                                       $password,
+                                       false,
+                                       false,
+                                       0,
+                                       $this->getVar( 'wgDBprefix' )
+                               );
+                               $grantableNames[] = $this->buildFullUserName( $dbUser, $server );
+                               $tryToCreate = false;
+                       } catch ( DBConnectionError $e ) {
+                               $tryToCreate = true;
+                       }
+               } else {
                        $grantableNames[] = $this->buildFullUserName( $dbUser, $server );
                        $tryToCreate = false;
-               } catch ( DBConnectionError $e ) {
-                       $tryToCreate = true;
                }
 
                if( $tryToCreate ) {