3 * PostgreSQL-specific installer.
10 * Class for setting up the MediaWiki database using Postgres.
15 class PostgresInstaller
extends DatabaseInstaller
{
17 protected $globalNames = array(
27 var $minimumVersion = '8.1';
33 public function isCompiled() {
34 return self
::checkExtension( 'pgsql' );
37 function getConnectForm() {
39 $this->getTextBox( 'wgDBserver', 'config-db-host' ) .
40 $this->parent
->getHelpBox( 'config-db-host-help' ) .
41 $this->getTextBox( 'wgDBport', 'config-db-port' ) .
42 Xml
::openElement( 'fieldset' ) .
43 Xml
::element( 'legend', array(), wfMsg( 'config-db-wiki-settings' ) ) .
44 $this->getTextBox( 'wgDBname', 'config-db-name' ) .
45 $this->parent
->getHelpBox( 'config-db-name-help' ) .
46 $this->getTextBox( 'wgDBmwschema', 'config-db-schema' ) .
47 $this->getTextBox( 'wgDBts2schema', 'config-db-ts2-schema' ) .
48 $this->parent
->getHelpBox( 'config-db-schema-help' ) .
49 Xml
::closeElement( 'fieldset' ) .
50 $this->getInstallUserBox();
53 function submitConnectForm() {
54 // Get variables from the request
55 $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport',
56 'wgDBname', 'wgDBmwschema', 'wgDBts2schema' ) );
59 $status = Status
::newGood();
60 if ( !strlen( $newValues['wgDBname'] ) ) {
61 $status->fatal( 'config-missing-db-name' );
62 } elseif ( !preg_match( '/^[a-zA-Z0-9_]+$/', $newValues['wgDBname'] ) ) {
63 $status->fatal( 'config-invalid-db-name', $newValues['wgDBname'] );
65 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBmwschema'] ) ) {
66 $status->fatal( 'config-invalid-schema', $newValues['wgDBmwschema'] );
68 if ( !preg_match( '/^[a-zA-Z0-9_]*$/', $newValues['wgDBts2schema'] ) ) {
69 $status->fatal( 'config-invalid-ts2schema', $newValues['wgDBts2schema'] );
73 if ( $status->isOK() ) {
74 $status->merge( $this->submitInstallUserBox() );
76 if ( !$status->isOK() ) {
81 if ( $status->isOK() ) {
82 $status->merge( $this->getConnection() );
84 if ( !$status->isOK() ) {
89 $version = $this->db
->getServerVersion();
90 if ( version_compare( $version, $this->minimumVersion
) < 0 ) {
91 return Status
::newFatal( 'config-postgres-old', $this->minimumVersion
, $version );
94 $this->setVar( 'wgDBuser', $this->getVar( '_InstallUser' ) );
95 $this->setVar( 'wgDBpassword', $this->getVar( '_InstallPassword' ) );
99 function getConnection() {
100 $status = Status
::newGood();
103 $this->db
= new DatabasePostgres(
104 $this->getVar( 'wgDBserver' ),
105 $this->getVar( '_InstallUser' ),
106 $this->getVar( '_InstallPassword' ),
107 $this->getVar( 'wgDBname' ) );
108 $status->value
= $this->db
;
109 } catch ( DBConnectionError
$e ) {
110 $status->fatal( 'config-connection-error', $e->getMessage() );
115 function setupDatabase() {
118 function getLocalSettings() {
119 $port = $this->getVar( 'wgDBport' );
120 $schema = $this->getVar( 'wgDBmwschema' );
121 $ts2 = $this->getVar( 'wgDBts2schema' );
123 "# Postgres specific settings
124 \$wgDBport = \"{$port}\";
125 \$wgDBmwschema = \"{$schema}\";
126 \$wgDBts2schema = \"{$ts2}\";";
129 public function doUpgrade() {