X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FPostgresInstaller.php;h=07284154dd3de4dce58f1bdf7f32e9d003251fff;hb=a0803c9bc551631c8a35bf2d99705a724cb62039;hp=c10e81afc0a953c672e796097cbdb57f30903726;hpb=c108dd32d9b0e6bfa78ed2d94625aa0a036f2689;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/PostgresInstaller.php b/includes/installer/PostgresInstaller.php index c10e81afc0..07284154dd 100644 --- a/includes/installer/PostgresInstaller.php +++ b/includes/installer/PostgresInstaller.php @@ -29,23 +29,23 @@ */ 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,12 +83,12 @@ class PostgresInstaller extends DatabaseInstaller { function submitConnectForm() { // Get variables from the request - $newValues = $this->setVarsFromRequest( array( + $newValues = $this->setVarsFromRequest( [ 'wgDBserver', 'wgDBport', 'wgDBname', 'wgDBmwschema' - ) ); + ] ); // Validate them $status = Status::newGood(); @@ -154,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() ); @@ -247,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' ) ); } @@ -258,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; @@ -293,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; } @@ -404,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 ); } @@ -425,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 @@ -446,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' ); @@ -481,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__ ); @@ -615,7 +615,7 @@ class PostgresInstaller extends DatabaseInstaller { $conn->commit( __METHOD__ ); } // Resume normal operations - if ( $status->isOk() ) { + if ( $status->isOK() ) { $this->enableLB(); } @@ -625,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() { @@ -643,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(); @@ -652,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 {