*/
class PostgresInstaller extends DatabaseInstaller {
- protected $globalNames = array(
+ protected $globalNames = [
'wgDBserver',
'wgDBport',
'wgDBname',
'wgDBuser',
'wgDBpassword',
'wgDBmwschema',
- );
+ ];
- protected $internalDefaults = array(
+ protected $internalDefaults = [
'_InstallUser' => 'postgres',
- );
+ ];
public $minimumVersion = '8.3';
public $maxRoleSearchDepth = 5;
- protected $pgConns = array();
+ protected $pgConns = [];
function getName() {
return 'postgres';
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() ) .
+ Html::element( 'legend', [], 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' )
) .
Html::closeElement( 'fieldset' ) .
function submitConnectForm() {
// Get variables from the request
- $newValues = $this->setVarsFromRequest( array(
+ $newValues = $this->setVarsFromRequest( [
'wgDBserver',
'wgDBport',
'wgDBname',
'wgDBmwschema'
- ) );
+ ] );
// Validate them
$status = Status::newGood();
protected function openConnectionWithParams( $user, $password, $dbName, $schema ) {
$status = Status::newGood();
try {
- $db = DatabaseBase::factory( 'postgres', array(
+ $db = DatabaseBase::factory( 'postgres', [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
'dbname' => $dbName,
- 'schema' => $schema ) );
+ 'schema' => $schema ] );
$status->value = $db;
} catch ( DBConnectionError $e ) {
$status->fatal( 'config-connection-error', $e->getMessage() );
}
public function openConnectionToAnyDB( $user, $password ) {
- $dbs = array(
+ $dbs = [
'template1',
'postgres',
- );
+ ];
if ( !in_array( $this->getVar( 'wgDBname' ), $dbs ) ) {
array_unshift( $dbs, $this->getVar( 'wgDBname' ) );
}
$status = Status::newGood();
foreach ( $dbs as $db ) {
try {
- $p = array(
+ $p = [
'host' => $this->getVar( 'wgDBserver' ),
'user' => $user,
'password' => $password,
'dbname' => $db
- );
+ ];
$conn = DatabaseBase::factory( 'postgres', $p );
} catch ( DBConnectionError $error ) {
$conn = false;
$superuser = $this->getVar( '_InstallUser' );
$row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
- array( 'rolname' => $superuser ), __METHOD__ );
+ [ 'rolname' => $superuser ], __METHOD__ );
return $row;
}
}
$conn = $status->value;
$installerId = $conn->selectField( '"pg_catalog"."pg_roles"', 'oid',
- array( 'rolname' => $this->getVar( '_InstallUser' ) ), __METHOD__ );
+ [ 'rolname' => $this->getVar( '_InstallUser' ) ], __METHOD__ );
$webId = $conn->selectField( '"pg_catalog"."pg_roles"', 'oid',
- array( 'rolname' => $this->getVar( 'wgDBuser' ) ), __METHOD__ );
+ [ 'rolname' => $this->getVar( 'wgDBuser' ) ], __METHOD__ );
return $this->isRoleMember( $conn, $installerId, $webId, $this->maxRoleSearchDepth );
}
return true;
}
// Get all members of the given group
- $res = $conn->select( '"pg_catalog"."pg_auth_members"', array( 'member' ),
- array( 'roleid' => $group ), __METHOD__ );
+ $res = $conn->select( '"pg_catalog"."pg_auth_members"', [ 'member' ],
+ [ 'roleid' => $group ], __METHOD__ );
foreach ( $res as $row ) {
if ( $row->member == $targetMember ) {
// Found target member
}
public function preInstall() {
- $createDbAccount = array(
+ $createDbAccount = [
'name' => 'user',
- 'callback' => array( $this, 'setupUser' ),
- );
- $commitCB = array(
+ 'callback' => [ $this, 'setupUser' ],
+ ];
+ $commitCB = [
'name' => 'pg-commit',
- 'callback' => array( $this, 'commitChanges' ),
- );
- $plpgCB = array(
+ 'callback' => [ $this, 'commitChanges' ],
+ ];
+ $plpgCB = [
'name' => 'pg-plpgsql',
- 'callback' => array( $this, 'setupPLpgSQL' ),
- );
- $schemaCB = array(
+ 'callback' => [ $this, 'setupPLpgSQL' ],
+ ];
+ $schemaCB = [
'name' => 'schema',
- 'callback' => array( $this, 'setupSchema' )
- );
+ 'callback' => [ $this, 'setupSchema' ]
+ ];
if ( $this->getVar( '_CreateDBAccount' ) ) {
$this->parent->addInstallStep( $createDbAccount, 'database' );
$dbName = $this->getVar( 'wgDBname' );
$exists = $conn->selectField( '"pg_catalog"."pg_database"', '1',
- array( 'datname' => $dbName ), __METHOD__ );
+ [ 'datname' => $dbName ], __METHOD__ );
if ( !$exists ) {
$safedb = $conn->addIdentifierQuotes( $dbName );
$conn->query( "CREATE DATABASE $safedb", __METHOD__ );
$conn->commit( __METHOD__ );
}
// Resume normal operations
- if ( $status->isOk() ) {
+ if ( $status->isOK() ) {
$this->enableLB();
}
public function getGlobalDefaults() {
// The default $wgDBmwschema is null, which breaks Postgres and other DBMSes that require
// the use of a schema, so we need to set it here
- return array_merge( parent::getGlobalDefaults(), array(
+ return array_merge( parent::getGlobalDefaults(), [
'wgDBmwschema' => 'mediawiki',
- ) );
+ ] );
}
public function setupPLpgSQL() {
$conn = $status->value;
$exists = $conn->selectField( '"pg_catalog"."pg_language"', 1,
- array( 'lanname' => 'plpgsql' ), __METHOD__ );
+ [ 'lanname' => 'plpgsql' ], __METHOD__ );
if ( $exists ) {
// Already exists, nothing to do
return Status::newGood();
// plpgsql is not installed, but if we have a pg_pltemplate table, we
// should be able to create it
$exists = $conn->selectField(
- array( '"pg_catalog"."pg_class"', '"pg_catalog"."pg_namespace"' ),
+ [ '"pg_catalog"."pg_class"', '"pg_catalog"."pg_namespace"' ],
1,
- array(
+ [
'pg_namespace.oid=relnamespace',
'nspname' => 'pg_catalog',
'relname' => 'pg_pltemplate',
- ),
+ ],
__METHOD__ );
if ( $exists ) {
try {