3 class PostgresInstaller
extends InstallerDBType
{
5 protected $globalNames = array(
15 protected $internalDefaults = array(
16 '_InstallUser' => 'postgres',
17 '_InstallPassword' => '',
20 var $minimumVersion = '8.1';
28 function isCompiled() {
29 return $this->checkExtension( 'pgsql' );
32 function getConnectForm() {
34 $this->getTextBox( 'wgDBserver', 'config-db-host' ) .
35 $this->parent
->getHelpBox( 'config-db-host-help' ) .
36 $this->getTextBox( 'wgDBport', 'config-db-port' ) .
37 Xml
::openElement( 'fieldset' ) .
38 Xml
::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) .
39 $this->getTextBox( 'wgDBname', 'config-db-name' ) .
40 $this->parent
->getHelpBox( 'config-db-name-help' ) .
41 $this->getTextBox( 'wgDBmwschema', 'config-db-schema' ) .
42 $this->getTextBox( 'wgDBts2schema', 'config-db-ts2-schema' ) .
43 $this->parent
->getHelpBox( 'config-db-schema-help' ) .
44 Xml
::closeElement( 'fieldset' ) .
45 $this->getInstallUserBox();
48 function submitConnectForm() {
49 // Get variables from the request
50 $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport',
51 'wgDBname', 'wgDBmwschema', 'wgDBts2schema' ) );
54 $status = Status
::newGood();
55 if ( !strlen( $newValues['wgDBname'] ) ) {
56 $status->fatal( 'config-missing-db-name' );
57 } elseif ( !preg_match( '/^[a-zA-Z0-9_]+$/', $newValues['wgDBname'] ) ) {
58 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
60 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) {
61 $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] );
63 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBts2schema'] ) ) {
64 $status->fatal( 'config-invalid-ts2schema', $newValues['wgDBts2schema'] );
68 if ( $status->isOK() ) {
69 $status->merge( $this->submitInstallUserBox() );
71 if ( !$status->isOK() ) {
76 if ( $status->isOK() ) {
77 $status->merge( $this->attemptConnection() );
79 if ( !$status->isOK() ) {
84 $version = $this->conn
->getServerVersion();
85 if ( version_compare( $version, $this->minimumVersion
) < 0 ) {
86 return Status
::newFatal( 'config-postgres-old', $this->minimumVersion
, $version );
91 function attemptConnection() {
92 $status = Status
::newGood();
95 $this->conn
= new DatabasePostgres(
96 $this->getVar( 'wgDBserver' ),
97 $this->getVar( '_InstallUser' ),
98 $this->getVar( '_InstallPassword' ),
100 $status->value
= $this->conn
;
101 } catch ( DBConnectionError
$e ) {
102 $status->fatal( 'config-connection-error', $e->getMessage() );
107 function getConnection() {
108 return $this->attemptConnection();
111 function getSettingsForm() {
115 function submitSettingsForm() {
116 return Status
::newGood();
119 function setupDatabase() {
122 function createTables() {
125 function getLocalSettings() {
126 $port = $this->getVar( 'wgDBport' );
127 $schema = $this->getVar( 'wgDBmwschema' );
128 $ts2 = $this->getVar( 'wgDBts2schema' );
130 "# Postgres specific settings
131 \$wgDBport = \"{$port}\";
132 \$wgDBmwschema = \"{$schema}\";
133 \$wgDBts2schema = \"{$ts2}\";";