r79950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r79949‎ | r79950 | r79951 >
Date:19:18, 10 January 2011
Author:demon
Status:deferred
Tags:
Comment:
More postgres
* Add user creation form like MySQL
* Fix canCreateAccounts() check
* Fix ts2 setup callback
* Still needs schema creation and other misc. stuff from lines ~370-530 of DatabasePostgres
Modified paths:
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -117,9 +117,8 @@
118118
119119 $superuser = $this->getVar( '_InstallUser' );
120120
121 - $rights = $conn->query( 'pg_catalog.pg_user',
122 - 'SELECT
123 - CASE WHEN usesuper IS TRUE THEN
 121+ $rights = $conn->selectField( 'pg_catalog.pg_user',
 122+ 'CASE WHEN usesuper IS TRUE THEN
124123 CASE WHEN usecreatedb IS TRUE THEN 3 ELSE 1 END
125124 ELSE CASE WHEN usecreatedb IS TRUE THEN 2 ELSE 0 END
126125 END AS rights',
@@ -137,6 +136,52 @@
138137 return true;
139138 }
140139
 140+ public function getSettingsForm() {
 141+ if ( $this->canCreateAccounts() ) {
 142+ $noCreateMsg = false;
 143+ } else {
 144+ $noCreateMsg = 'config-db-web-no-create-privs';
 145+ }
 146+ $s = $this->getWebUserBox( $noCreateMsg );
 147+
 148+ return $s;
 149+ }
 150+
 151+ public function submitSettingsForm() {
 152+ $status = $this->submitWebUserBox();
 153+ if ( !$status->isOK() ) {
 154+ return $status;
 155+ }
 156+
 157+ // Validate the create checkbox
 158+ $canCreate = $this->canCreateAccounts();
 159+ if ( !$canCreate ) {
 160+ $this->setVar( '_CreateDBAccount', false );
 161+ $create = false;
 162+ } else {
 163+ $create = $this->getVar( '_CreateDBAccount' );
 164+ }
 165+
 166+ if ( !$create ) {
 167+ // Test the web account
 168+ try {
 169+ new DatabasePostgres(
 170+ $this->getVar( 'wgDBserver' ),
 171+ $this->getVar( 'wgDBuser' ),
 172+ $this->getVar( 'wgDBpassword' ),
 173+ false,
 174+ false,
 175+ 0,
 176+ $this->getVar( 'wgDBprefix' )
 177+ );
 178+ } catch ( DBConnectionError $e ) {
 179+ return Status::newFatal( 'config-connection-error', $e->getMessage() );
 180+ }
 181+ }
 182+
 183+ return Status::newGood();
 184+ }
 185+
141186 public function preInstall() {
142187 $commitCB = array(
143188 'name' => 'pg-commit',
@@ -152,6 +197,7 @@
153198 );
154199 $this->parent->addInstallStep( $commitCB, 'interwiki' );
155200 $this->parent->addInstallStep( $userCB );
 201+ $this->parent->addInstallStep( $ts2CB, 'setupDatabase' );
156202 }
157203
158204 function setupDatabase() {
@@ -161,23 +207,23 @@
162208 }
163209 $conn = $status->value;
164210
165 - // Make sure that we can write to the correct schema
166 - // If not, Postgres will happily and silently go to the next search_path item
167 - $schema = $this->getVar( 'wgDBmwschema' );
168 - $ctest = 'mediawiki_test_table';
169 - $safeschema = $conn->addIdentifierQuotes( $schema );
170 - if ( $conn->tableExists( $ctest, $schema ) ) {
171 - $conn->query( "DROP TABLE $safeschema.$ctest" );
172 - }
173 - $res = $conn->query( "CREATE TABLE $safeschema.$ctest(a int)" );
174 - if ( !$res ) {
175 - $status->fatal( 'config-install-pg-schema-failed',
176 - $this->getVar( 'wgDBuser'), $schema );
177 - }
178 - $conn->query( "DROP TABLE $safeschema.$ctest" );
179 -
180211 $dbName = $this->getVar( 'wgDBname' );
181212 if( !$conn->selectDB( $dbName ) ) {
 213+ // Make sure that we can write to the correct schema
 214+ // If not, Postgres will happily and silently go to the next search_path item
 215+ $schema = $this->getVar( 'wgDBmwschema' );
 216+ $ctest = 'mediawiki_test_table';
 217+ $safeschema = $conn->addIdentifierQuotes( $schema );
 218+ if ( $conn->tableExists( $ctest, $schema ) ) {
 219+ $conn->query( "DROP TABLE $safeschema.$ctest" );
 220+ }
 221+ $res = $conn->query( "CREATE TABLE $safeschema.$ctest(a int)" );
 222+ if ( !$res ) {
 223+ $status->fatal( 'config-install-pg-schema-failed',
 224+ $this->getVar( 'wgDBuser'), $schema );
 225+ }
 226+ $conn->query( "DROP TABLE $safeschema.$ctest" );
 227+
182228 $safedb = $conn->addIdentifierQuotes( $dbName );
183229 $safeuser = $conn->addQuotes( $this->getVar( 'wgDBuser' ) );
184230 $conn->query( "CREATE DATABASE $safedb OWNER $safeuser", __METHOD__ );

Follow-up revisions

RevisionCommit summaryAuthorDate
r81182MFT a bunch of installer fixes. r80238, r80128, r80124, r80083, r80080, r800...demon01:59, 29 January 2011

Status & tagging log