From: Mark A. Hershberger Date: Fri, 4 Feb 2011 00:15:44 +0000 (+0000) Subject: * make canCreateAccounts() return Status Objects instead of boolean X-Git-Tag: 1.31.0-rc.0~32217 X-Git-Url: http://git.cyclocoop.org/%24action?a=commitdiff_plain;h=5e1e89c63fd9829f1e3a1b4237d0d65153f2cbec;p=lhc%2Fweb%2Fwiklou.git * make canCreateAccounts() return Status Objects instead of boolean * re-use openConnection to test the ability of the user to connect. --- diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 4a153ec249..311e7d23dc 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -137,15 +137,11 @@ class PostgresInstaller extends DatabaseInstaller { array( 'usename' => $superuser ), __METHOD__ ); - if( !$rights ) { - return false; - } - - if( $rights != 1 && $rights != 3 ) { - return false; + if( !$rights || ( $rights != 1 && $rights != 3 ) ) { + $status = Status::newFatal("can't create"); } - return true; + return $status; } public function getSettingsForm() { @@ -166,26 +162,21 @@ class PostgresInstaller extends DatabaseInstaller { } // Validate the create checkbox + $create = true; $canCreate = $this->canCreateAccounts(); - if ( !$canCreate ) { + if ( !$canCreate->isOK() ) { $this->setVar( '_CreateDBAccount', false ); $create = false; } else { $create = $this->getVar( '_CreateDBAccount' ); } - if ( !$create ) { + // Don't test the web account if it is the same as the admin. + if ( !$create && $this->getVar( 'wgDBuser' ) != $this->getVar( '_InstallUser' ) ) { // Test the web account try { - new DatabasePostgres( - $this->getVar( 'wgDBserver' ), - $this->getVar( 'wgDBuser' ), - $this->getVar( 'wgDBpassword' ), - false, - false, - 0, - $this->getVar( 'wgDBprefix' ) - ); + $this->useAdmin = FALSE; + return $this->openConnection(); } catch ( DBConnectionError $e ) { return Status::newFatal( 'config-connection-error', $e->getMessage() ); }