r81495 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81494‎ | r81495 | r81496 >
Date:00:15, 4 February 2011
Author:mah
Status:reverted
Tags:
Comment:
* make canCreateAccounts() return Status Objects instead of boolean
* re-use openConnection to test the ability of the user to connect.
Modified paths:
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -137,15 +137,11 @@
138138 array( 'usename' => $superuser ), __METHOD__
139139 );
140140
141 - if( !$rights ) {
142 - return false;
 141+ if( !$rights || ( $rights != 1 && $rights != 3 ) ) {
 142+ $status = Status::newFatal("can't create");
143143 }
144144
145 - if( $rights != 1 && $rights != 3 ) {
146 - return false;
147 - }
148 -
149 - return true;
 145+ return $status;
150146 }
151147
152148 public function getSettingsForm() {
@@ -166,26 +162,21 @@
167163 }
168164
169165 // Validate the create checkbox
 166+ $create = true;
170167 $canCreate = $this->canCreateAccounts();
171 - if ( !$canCreate ) {
 168+ if ( !$canCreate->isOK() ) {
172169 $this->setVar( '_CreateDBAccount', false );
173170 $create = false;
174171 } else {
175172 $create = $this->getVar( '_CreateDBAccount' );
176173 }
177174
178 - if ( !$create ) {
 175+ // Don't test the web account if it is the same as the admin.
 176+ if ( !$create && $this->getVar( 'wgDBuser' ) != $this->getVar( '_InstallUser' ) ) {
179177 // Test the web account
180178 try {
181 - new DatabasePostgres(
182 - $this->getVar( 'wgDBserver' ),
183 - $this->getVar( 'wgDBuser' ),
184 - $this->getVar( 'wgDBpassword' ),
185 - false,
186 - false,
187 - 0,
188 - $this->getVar( 'wgDBprefix' )
189 - );
 179+ $this->useAdmin = FALSE;
 180+ return $this->openConnection();
190181 } catch ( DBConnectionError $e ) {
191182 return Status::newFatal( 'config-connection-error', $e->getMessage() );
192183 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r81497re r81495 — you know, I've completely forgotten why I wanted to return a st...mah00:21, 4 February 2011

Status & tagging log