r71189 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r71188‎ | r71189 | r71190 >
Date:03:07, 17 August 2010
Author:mah
Status:ok
Tags:
Comment:
OverloardQ or other PG person, please review
These patches were necessary to get new-installer working on PG for me. I'm not sure about the ‘create lang' bits — they should maybe be in another step?
Modified paths:
  • /trunk/phase3/includes/installer/DatabaseInstaller.php (modified) (history)
  • /trunk/phase3/includes/installer/PostgresInstaller.php (modified) (history)
  • /trunk/phase3/maintenance/postgres/tables.sql (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/postgres/tables.sql
@@ -72,6 +72,7 @@
7373 CREATE INDEX page_random_idx ON page (page_random);
7474 CREATE INDEX page_len_idx ON page (page_len);
7575
 76+CREATE LANGUAGE 'plpgsql';
7677 CREATE FUNCTION page_deleted() RETURNS TRIGGER LANGUAGE plpgsql AS
7778 $mw$
7879 BEGIN
Index: trunk/phase3/includes/installer/DatabaseInstaller.php
@@ -302,11 +302,11 @@
303303 if ( !$status->isOK() ) {
304304 return false;
305305 }
306 - $conn = $status->value;
307 - if ( !$conn->selectDB( $this->getVar( 'wgDBname' ) ) ) {
 306+
 307+ if ( !$this->db->selectDB( $this->getVar( 'wgDBname' ) ) ) {
308308 return false;
309309 }
310 - return $conn->tableExists( 'cur' ) || $conn->tableExists( 'revision' );
 310+ return $this->db->tableExists( 'cur' ) || $this->db->tableExists( 'revision' );
311311 }
312312
313313 /**
Index: trunk/phase3/includes/installer/PostgresInstaller.php
@@ -18,15 +18,8 @@
1919 'wgDBts2schema',
2020 );
2121
22 - protected $internalDefaults = array(
23 - '_InstallUser' => 'postgres',
24 - '_InstallPassword' => '',
25 - );
26 -
2722 var $minimumVersion = '8.1';
2823
29 - var $conn;
30 -
3124 function getName() {
3225 return 'postgres';
3326 }
@@ -80,40 +73,39 @@
8174
8275 // Try to connect
8376 if ( $status->isOK() ) {
84 - $status->merge( $this->attemptConnection() );
 77+ $status->merge( $this->getConnection() );
8578 }
8679 if ( !$status->isOK() ) {
8780 return $status;
8881 }
8982
9083 // Check version
91 - $version = $this->conn->getServerVersion();
 84+ $version = $this->db->getServerVersion();
9285 if ( version_compare( $version, $this->minimumVersion ) < 0 ) {
9386 return Status::newFatal( 'config-postgres-old', $this->minimumVersion, $version );
9487 }
 88+
 89+ $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
 90+ $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
9591 return $status;
9692 }
9793
98 - function attemptConnection() {
 94+ function getConnection() {
9995 $status = Status::newGood();
10096
10197 try {
102 - $this->conn = new DatabasePostgres(
 98+ $this->db = new DatabasePostgres(
10399 $this->getVar( 'wgDBserver' ),
104100 $this->getVar( '_InstallUser' ),
105101 $this->getVar( '_InstallPassword' ),
106 - 'postgres' );
107 - $status->value = $this->conn;
 102+ $this->getVar( 'wgDBname' ) );
 103+ $status->value = $this->db;
108104 } catch ( DBConnectionError $e ) {
109105 $status->fatal( 'config-connection-error', $e->getMessage() );
110106 }
111107 return $status;
112108 }
113109
114 - function getConnection() {
115 - return $this->attemptConnection();
116 - }
117 -
118110 function getSettingsForm() {
119111 return false;
120112 }
@@ -126,8 +118,21 @@
127119 }
128120
129121 function createTables() {
 122+ $status = $this->getConnection();
 123+ if ( !$status->isOK() ) {
 124+ return $status;
130125 }
 126+ $this->db->selectDB( $this->getVar( 'wgDBname' ) );
131127
 128+ global $IP;
 129+ $err = $this->db->sourceFile( "$IP/maintenance/postgres/tables.sql" );
 130+ if ( $err !== true ) {
 131+ //@todo or...?
 132+ $this->db->reportQueryError( $err, 0, $sql, __FUNCTION__ );
 133+ }
 134+ return Status::newGood();
 135+ }
 136+
132137 function getLocalSettings() {
133138 $port = $this->getVar( 'wgDBport' );
134139 $schema = $this->getVar( 'wgDBmwschema' );

Status & tagging log