Merge "Improve sign-up portion of the login form"
[lhc/web/wiklou.git] / includes / installer / PostgresInstaller.php
index cb40f88..0728415 100644 (file)
  */
 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';
@@ -59,22 +59,22 @@ class PostgresInstaller extends DatabaseInstaller {
                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' ) .
@@ -83,7 +83,12 @@ class PostgresInstaller extends DatabaseInstaller {
 
        function submitConnectForm() {
                // Get variables from the request
-               $newValues = $this->setVarsFromRequest( array( 'wgDBserver', 'wgDBport', 'wgDBname', 'wgDBmwschema' ) );
+               $newValues = $this->setVarsFromRequest( [
+                       'wgDBserver',
+                       'wgDBport',
+                       'wgDBname',
+                       'wgDBmwschema'
+               ] );
 
                // Validate them
                $status = Status::newGood();
@@ -149,12 +154,12 @@ class PostgresInstaller extends DatabaseInstaller {
        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() );
@@ -242,10 +247,10 @@ class PostgresInstaller extends DatabaseInstaller {
        }
 
        public function openConnectionToAnyDB( $user, $password ) {
-               $dbs = array(
+               $dbs = [
                        'template1',
                        'postgres',
-               );
+               ];
                if ( !in_array( $this->getVar( 'wgDBname' ), $dbs ) ) {
                        array_unshift( $dbs, $this->getVar( 'wgDBname' ) );
                }
@@ -253,12 +258,12 @@ class PostgresInstaller extends DatabaseInstaller {
                $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;
@@ -288,7 +293,7 @@ class PostgresInstaller extends DatabaseInstaller {
                $superuser = $this->getVar( '_InstallUser' );
 
                $row = $conn->selectRow( '"pg_catalog"."pg_roles"', '*',
-                       array( 'rolname' => $superuser ), __METHOD__ );
+                       [ 'rolname' => $superuser ], __METHOD__ );
 
                return $row;
        }
@@ -399,9 +404,9 @@ class PostgresInstaller extends DatabaseInstaller {
                }
                $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 );
        }
@@ -420,8 +425,8 @@ class PostgresInstaller extends DatabaseInstaller {
                        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
@@ -441,22 +446,22 @@ class PostgresInstaller extends DatabaseInstaller {
        }
 
        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' );
@@ -476,7 +481,7 @@ class PostgresInstaller extends DatabaseInstaller {
                $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__ );
@@ -610,7 +615,7 @@ class PostgresInstaller extends DatabaseInstaller {
                        $conn->commit( __METHOD__ );
                }
                // Resume normal operations
-               if ( $status->isOk() ) {
+               if ( $status->isOK() ) {
                        $this->enableLB();
                }
 
@@ -620,9 +625,9 @@ class PostgresInstaller extends DatabaseInstaller {
        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() {
@@ -638,7 +643,7 @@ class PostgresInstaller extends DatabaseInstaller {
                $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();
@@ -647,13 +652,13 @@ class PostgresInstaller extends DatabaseInstaller {
                // 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 {