r81584 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81583‎ | r81584 | r81585 >
Date:03:06, 6 February 2011
Author:mah
Status:ok
Tags:
Comment:
Make schema selection really work for PostgreSQL installation
Modified paths:
  • /trunk/phase3/includes/db/DatabasePostgres.php (modified) (history)
  • /trunk/phase3/includes/installer/Installer.i18n.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/db/DatabasePostgres.php
@@ -195,7 +195,6 @@
196196
197197 global $wgDBmwschema;
198198 if ( isset( $wgDBmwschema )
199 - && $wgDBmwschema !== 'mediawiki'
200199 && preg_match( '/^\w+$/', $wgDBmwschema )
201200 ) {
202201 $safeschema = $this->addIdentifierQuotes( $wgDBmwschema );
Index: trunk/phase3/includes/installer/Installer.i18n.php
@@ -444,6 +444,7 @@
445445 'config-install-step-failed' => 'failed',
446446 'config-install-extensions' => 'Including extensions',
447447 'config-install-database' => 'Setting up database',
 448+ 'config-install-pg-schema-not-exist' => 'PostgreSQL schema does not exist',
448449 'config-install-pg-schema-failed' => 'Tables creation failed.
449450 Make sure that the user "$1" can write to the schema "$2".',
450451 'config-install-pg-commit' => 'Committing changes',
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -226,15 +226,12 @@
227227
228228 $conn->query( "CREATE DATABASE $safedb OWNER $safeuser", __METHOD__ );
229229
230 - $conn = new DatabasePostgres(
231 - $this->getVar( 'wgDBserver' ),
232 - $this->getVar( 'wgDBuser' ),
233 - $this->getVar( 'wgDBpassword' ),
234 - $dbName,
235 - false,
236 - 0,
237 - $this->getVar( 'wgDBprefix' )
238 - );
 230+ $this->useAdmin = false;
 231+ $status = $this->getConnection();
 232+ if ( !$status->isOK() ) {
 233+ return $status;
 234+ }
 235+ $conn = $status->value;
239236
240237 $result = $conn->schemaExists( $schema );
241238 if( !$result ) {
@@ -253,6 +250,7 @@
254251 "pg_catalog.oidvectortypes(p.proargtypes)||') TO $safeuser;'\n" .
255252 "FROM pg_catalog.pg_proc p, pg_catalog.pg_namespace n\n" .
256253 "WHERE p.pronamespace = n.oid AND n.nspname = $safeschema2";
 254+ $conn->query( "SET search_path = $safeschema" );
257255 $res = $conn->query( $SQL );
258256 }
259257 }
@@ -316,6 +314,9 @@
317315 }
318316
319317 public function createTables() {
 318+ $schema = $this->getVar( 'wgDBmwschema' );
 319+ $user = $this->getVar( 'wgDBuser' );
 320+
320321 $this->db = null;
321322 $this->useAdmin = false;
322323 $status = $this->getConnection();
@@ -332,6 +333,13 @@
333334 $this->db->setFlag( DBO_DDLMODE ); // For Oracle's handling of schema files
334335 $this->db->begin( __METHOD__ );
335336
 337+
 338+ if( !$this->db->schemaExists( $schema ) ) {
 339+ $status->error( 'config-install-pg-schema-not-exist' );
 340+ return $status;
 341+ }
 342+ $safeschema = $this->db->addIdentifierQuotes( $schema );
 343+ $this->db->query( "SET search_path = $safeschema" );
336344 $error = $this->db->sourceFile( $this->db->getSchema() );
337345 if( $error !== true ) {
338346 $this->db->reportQueryError( $error, 0, '', __METHOD__ );

Status & tagging log