diff options
Diffstat (limited to 'includes/installer/PostgresInstaller.php')
-rw-r--r-- | includes/installer/PostgresInstaller.php | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index 4e5ae8cf..2cf41564 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -42,8 +42,8 @@ class PostgresInstaller extends DatabaseInstaller { '_InstallUser' => 'postgres', ); - var $minimumVersion = '8.3'; - var $maxRoleSearchDepth = 5; + public $minimumVersion = '8.3'; + public $maxRoleSearchDepth = 5; protected $pgConns = array(); @@ -56,13 +56,27 @@ class PostgresInstaller extends DatabaseInstaller { } function getConnectForm() { - return - $this->getTextBox( 'wgDBserver', 'config-db-host', array(), $this->parent->getHelpBox( 'config-db-host-help' ) ) . + return $this->getTextBox( + 'wgDBserver', + 'config-db-host', + array(), + $this->parent->getHelpBox( 'config-db-host-help' ) + ) . $this->getTextBox( 'wgDBport', 'config-db-port' ) . Html::openElement( 'fieldset' ) . Html::element( 'legend', array(), wfMessage( 'config-db-wiki-settings' )->text() ) . - $this->getTextBox( 'wgDBname', 'config-db-name', array(), $this->parent->getHelpBox( 'config-db-name-help' ) ) . - $this->getTextBox( 'wgDBmwschema', 'config-db-schema', array(), $this->parent->getHelpBox( 'config-db-schema-help' ) ) . + $this->getTextBox( + 'wgDBname', + 'config-db-name', + array(), + $this->parent->getHelpBox( 'config-db-name-help' ) + ) . + $this->getTextBox( + 'wgDBmwschema', + 'config-db-schema', + array(), + $this->parent->getHelpBox( 'config-db-schema-help' ) + ) . Html::closeElement( 'fieldset' ) . $this->getInstallUserBox(); } @@ -108,6 +122,7 @@ class PostgresInstaller extends DatabaseInstaller { $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) ); $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) ); + return Status::newGood(); } @@ -116,6 +131,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( $status->isOK() ) { $this->db = $status->value; } + return $status; } @@ -137,11 +153,13 @@ class PostgresInstaller extends DatabaseInstaller { $this->getVar( 'wgDBserver' ), $user, $password, - $dbName); + $dbName + ); $status->value = $db; } catch ( DBConnectionError $e ) { $status->fatal( 'config-connection-error', $e->getMessage() ); } + return $status; } @@ -165,6 +183,7 @@ class PostgresInstaller extends DatabaseInstaller { $conn->commit( __METHOD__ ); $this->pgConns[$type] = $conn; } + return $status; } @@ -215,6 +234,7 @@ class PostgresInstaller extends DatabaseInstaller { $safeRole = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) ); $conn->query( "SET ROLE $safeRole" ); } + return $status; default: throw new MWException( "Invalid special connection type: \"$type\"" ); @@ -267,6 +287,7 @@ class PostgresInstaller extends DatabaseInstaller { $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*', array( 'rolname' => $superuser ), __METHOD__ ); + return $row; } @@ -275,6 +296,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$perms ) { return false; } + return $perms->rolsuper === 't' || $perms->rolcreaterole === 't'; } @@ -283,6 +305,7 @@ class PostgresInstaller extends DatabaseInstaller { if ( !$perms ) { return false; } + return $perms->rolsuper === 't'; } @@ -331,6 +354,7 @@ class PostgresInstaller extends DatabaseInstaller { } else { $msg = 'config-install-user-missing'; } + return Status::newFatal( $msg, $this->getVar( 'wgDBuser' ) ); } @@ -410,6 +434,7 @@ class PostgresInstaller extends DatabaseInstaller { } } } + return false; } @@ -431,7 +456,7 @@ class PostgresInstaller extends DatabaseInstaller { 'callback' => array( $this, 'setupSchema' ) ); - if( $this->getVar( '_CreateDBAccount' ) ) { + if ( $this->getVar( '_CreateDBAccount' ) ) { $this->parent->addInstallStep( $createDbAccount, 'database' ); } $this->parent->addInstallStep( $commitCB, 'interwiki' ); @@ -454,6 +479,7 @@ class PostgresInstaller extends DatabaseInstaller { $safedb = $conn->addIdentifierQuotes( $dbName ); $conn->query( "CREATE DATABASE $safedb", __METHOD__ ); } + return Status::newGood(); } @@ -469,7 +495,7 @@ class PostgresInstaller extends DatabaseInstaller { $schema = $this->getVar( 'wgDBmwschema' ); $safeschema = $conn->addIdentifierQuotes( $schema ); $safeuser = $conn->addIdentifierQuotes( $this->getVar( 'wgDBuser' ) ); - if( !$conn->schemaExists( $schema ) ) { + if ( !$conn->schemaExists( $schema ) ) { try { $conn->query( "CREATE SCHEMA $safeschema AUTHORIZATION $safeuser" ); } catch ( DBQueryError $e ) { @@ -480,11 +506,13 @@ class PostgresInstaller extends DatabaseInstaller { // Select the new schema in the current connection $conn->determineCoreSchema( $schema ); + return Status::newGood(); } function commitChanges() { $this->db->commit( __METHOD__ ); + return Status::newGood(); } @@ -529,8 +557,8 @@ class PostgresInstaller extends DatabaseInstaller { function getLocalSettings() { $port = $this->getVar( 'wgDBport' ); $schema = $this->getVar( 'wgDBmwschema' ); - return -"# Postgres specific settings + + return "# Postgres specific settings \$wgDBport = \"{$port}\"; \$wgDBmwschema = \"{$schema}\";"; } @@ -557,20 +585,22 @@ class PostgresInstaller extends DatabaseInstaller { */ $conn = $status->value; - if( $conn->tableExists( 'archive' ) ) { + if ( $conn->tableExists( 'archive' ) ) { $status->warning( 'config-install-tables-exist' ); $this->enableLB(); + return $status; } $conn->begin( __METHOD__ ); - if( !$conn->schemaExists( $schema ) ) { + if ( !$conn->schemaExists( $schema ) ) { $status->fatal( 'config-install-pg-schema-not-exist' ); + return $status; } $error = $conn->sourceFile( $conn->getSchemaPath() ); - if( $error !== true ) { + if ( $error !== true ) { $conn->reportQueryError( $error, 0, '', __METHOD__ ); $conn->rollback( __METHOD__ ); $status->fatal( 'config-install-tables-failed', $error ); @@ -578,9 +608,10 @@ class PostgresInstaller extends DatabaseInstaller { $conn->commit( __METHOD__ ); } // Resume normal operations - if( $status->isOk() ) { + if ( $status->isOk() ) { $this->enableLB(); } + return $status; } @@ -623,6 +654,7 @@ class PostgresInstaller extends DatabaseInstaller { } else { return Status::newFatal( 'config-pg-no-plpgsql', $this->getVar( 'wgDBname' ) ); } + return Status::newGood(); } } |