MediaWiki master
MediaWiki\Installer\PostgresInstaller Class Reference

Class for setting up the MediaWiki database using Postgres. More...

Inherits MediaWiki\Installer\DatabaseInstaller.

Collaboration diagram for MediaWiki\Installer\PostgresInstaller:

Public Member Functions

 canCreateAccounts ()
 
 canCreateObjectsForWebUser ()
 Returns true if the install user is able to create objects owned by the web user, false otherwise.
 
 getConnectForm (WebInstaller $webInstaller)
 
 getGlobalDefaults ()
 Get a name=>value map of MW configuration globals for the default values.
 
 getLocalSettings ()
 Get the DBMS-specific options for LocalSettings.php generation.
 
 getName ()
 Return the internal name, e.g.
 
 getSettingsForm (WebInstaller $webInstaller)
 
 isCompiled ()
 
 openConnectionToAnyDB ( $user, $password)
 
 preInstall ()
 Allow DB installers a chance to make last-minute changes before installation occurs.
 
 preUpgrade ()
 Allow DB installers a chance to make checks before upgrade.
 
 setupDatabase ()
 Create the database and return a Status object indicating success or failure.
 
 setupPLpgSQL ()
 
 setupSchema ()
 
 setupUser ()
 
- Public Member Functions inherited from MediaWiki\Installer\DatabaseInstaller
 __construct ( $parent)
 Construct and initialise parent.
 
 checkPrerequisites ()
 Checks for installation prerequisites other than those checked by isCompiled()
 
 createExtensionTables ()
 Create the tables for each extension the user enabled.
 
 createTables ()
 Create database tables from scratch from the automatically generated file.
 
 definitelyGetConnection (string $type)
 Get a connection and unwrap it from its Status object, throwing an exception on failure.
 
 enableLB ()
 
 getConnection ( $type=self::CONN_DONT_KNOW)
 Connect to the database using the administrative user/password currently defined in the session.
 
 getGlobalNames ()
 Get an array of MW configuration globals that will be configured by this class.
 
 getInternalDefaults ()
 Get a name=>value map of internal variables used during installation.
 
 getReadableName ()
 Get the internationalised name for this DBMS.
 
 getSchemaVars ()
 Override this to provide DBMS-specific schema variables, to be substituted into tables.sql and other schema files.
 
 getVar ( $var, $default=null)
 Get a variable, taking local defaults into account.
 
 insertUpdateKeys ()
 Insert update keys into table to prevent running unneeded updates.
 
 needsUpgrade ()
 Determine whether an existing installation of MediaWiki is present in the configured administrative connection.
 
 populateInterwikiTable ()
 Common function for databases that don't understand the MySQLish syntax of interwiki.list.
 
 setVar ( $name, $value)
 Convenience alias for $this->parent->setVar()
 

Public Attributes

int $maxRoleSearchDepth = 5
 
- Public Attributes inherited from MediaWiki\Installer\DatabaseInstaller
Database $db = null
 
Installer $parent
 The Installer object.
 
const CONN_CREATE_DATABASE = 'create-database'
 A connection for creating DBs, suitable for pre-installation.
 
const CONN_CREATE_SCHEMA = 'create-schema'
 A connection to the new DB, for creating schemas and other similar objects in the new DB.
 
const CONN_CREATE_TABLES = 'create-tables'
 A connection with a role suitable for creating tables.
 
const CONN_DONT_KNOW = 'dont-know'
 Legacy default connection type.
 

Static Public Attributes

static $minimumVersion = '10'
 
- Static Public Attributes inherited from MediaWiki\Installer\DatabaseInstaller
static string $minimumVersion
 Set by subclasses.
 

Protected Member Functions

 changeConnTypeFromSchemaToTables (Database $conn)
 Change the type of a connection from CONN_CREATE_SCHEMA to CONN_CREATE_TABLES.
 
 getInstallUserPermissions ()
 
 isRoleMember ( $conn, $targetMember, $group, $maxDepth)
 Recursive helper for canCreateObjectsForWebUser().
 
 isSuperUser ()
 
 openConnection (string $type)
 Get a connection of a specific PostgreSQL-specific type.
 
 openConnectionWithParams ( $user, $password, $dbName, $schema)
 Open a PG connection with given parameters.
 
- Protected Member Functions inherited from MediaWiki\Installer\DatabaseInstaller
 changeConnType (Database $conn, &$storedType, $newType)
 Change the type of a connection.
 
 selectDatabase (Database $conn, string $database)
 

Protected Attributes

 $globalNames
 
 $internalDefaults
 
- Protected Attributes inherited from MediaWiki\Installer\DatabaseInstaller
array $globalNames = []
 Array of MW configuration globals this class uses.
 
array $internalDefaults = []
 Internal variables for installation.
 

Static Protected Attributes

static $notMinimumVersionMessage = 'config-postgres-old'
 
- Static Protected Attributes inherited from MediaWiki\Installer\DatabaseInstaller
static string $notMinimumVersionMessage
 Set by subclasses.
 

Additional Inherited Members

- Static Public Member Functions inherited from MediaWiki\Installer\DatabaseInstaller
static meetsMinimumRequirement (IDatabase $conn)
 Whether the provided version meets the necessary requirements for this type.
 
- Static Protected Member Functions inherited from MediaWiki\Installer\DatabaseInstaller
static checkExtension ( $name)
 Convenience function.
 

Detailed Description

Class for setting up the MediaWiki database using Postgres.

Since
1.17

Definition at line 41 of file PostgresInstaller.php.

Member Function Documentation

◆ canCreateAccounts()

MediaWiki\Installer\PostgresInstaller::canCreateAccounts ( )

Definition at line 225 of file PostgresInstaller.php.

◆ canCreateObjectsForWebUser()

MediaWiki\Installer\PostgresInstaller::canCreateObjectsForWebUser ( )

Returns true if the install user is able to create objects owned by the web user, false otherwise.

Returns
bool

Definition at line 240 of file PostgresInstaller.php.

◆ changeConnTypeFromSchemaToTables()

MediaWiki\Installer\PostgresInstaller::changeConnTypeFromSchemaToTables ( Database $conn)
protected

Change the type of a connection from CONN_CREATE_SCHEMA to CONN_CREATE_TABLES.

Postgres overrides this.

Parameters
Database$conn
Returns
ConnectionStatus

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 157 of file PostgresInstaller.php.

References Wikimedia\Rdbms\Database\addIdentifierQuotes(), and Wikimedia\Rdbms\Database\query().

◆ getConnectForm()

MediaWiki\Installer\PostgresInstaller::getConnectForm ( WebInstaller $webInstaller)

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 74 of file PostgresInstaller.php.

◆ getGlobalDefaults()

MediaWiki\Installer\PostgresInstaller::getGlobalDefaults ( )

Get a name=>value map of MW configuration globals for the default values.

Returns
array

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 416 of file PostgresInstaller.php.

◆ getInstallUserPermissions()

MediaWiki\Installer\PostgresInstaller::getInstallUserPermissions ( )
protected

Definition at line 211 of file PostgresInstaller.php.

◆ getLocalSettings()

MediaWiki\Installer\PostgresInstaller::getLocalSettings ( )

Get the DBMS-specific options for LocalSettings.php generation.

Returns
string

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 396 of file PostgresInstaller.php.

◆ getName()

MediaWiki\Installer\PostgresInstaller::getName ( )

Return the internal name, e.g.

'mysql', or 'sqlite'.

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 66 of file PostgresInstaller.php.

◆ getSettingsForm()

MediaWiki\Installer\PostgresInstaller::getSettingsForm ( WebInstaller $webInstaller)

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 78 of file PostgresInstaller.php.

◆ isCompiled()

MediaWiki\Installer\PostgresInstaller::isCompiled ( )
Returns
bool Returns true if the client library is compiled in.

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 70 of file PostgresInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\checkExtension().

◆ isRoleMember()

MediaWiki\Installer\PostgresInstaller::isRoleMember ( $conn,
$targetMember,
$group,
$maxDepth )
protected

Recursive helper for canCreateObjectsForWebUser().

Parameters
Database$conn
int$targetMemberRole ID of the member to look for
int$groupRole ID of the group to look for
int$maxDepthMaximum recursive search depth
Returns
bool

Definition at line 266 of file PostgresInstaller.php.

◆ isSuperUser()

MediaWiki\Installer\PostgresInstaller::isSuperUser ( )
protected

Definition at line 230 of file PostgresInstaller.php.

◆ openConnection()

MediaWiki\Installer\PostgresInstaller::openConnection ( string $type)
protected

Get a connection of a specific PostgreSQL-specific type.

Connections of a given type are cached.

PostgreSQL lacks cross-database operations, so after the new database is created, you need to make a separate connection to connect to that database and add tables to it.

New tables are owned by the user that creates them, and MediaWiki's PostgreSQL support has always assumed that the table owner will be $wgDBuser. So before we create new tables, we either need to either connect as the other user or to execute a SET ROLE command. Using a separate connection for this allows us to avoid accidental cross-module dependencies.

Parameters
string$typeThe type of connection to get:
  • self::CONN_CREATE_DATABASE: A connection for creating DBs, suitable for pre- installation.
  • self::CONN_CREATE_SCHEMA: A connection to the new DB, for creating schemas and other similar objects in the new DB.
  • self::CONN_CREATE_TABLES: A connection with a role suitable for creating tables.
Returns
ConnectionStatus On success, a connection object will be in the value member.

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 133 of file PostgresInstaller.php.

◆ openConnectionToAnyDB()

MediaWiki\Installer\PostgresInstaller::openConnectionToAnyDB ( $user,
$password )

Definition at line 174 of file PostgresInstaller.php.

References StatusValue\fatal().

◆ openConnectionWithParams()

MediaWiki\Installer\PostgresInstaller::openConnectionWithParams ( $user,
$password,
$dbName,
$schema )
protected

Open a PG connection with given parameters.

Parameters
string$userUser name
string$password
string$dbNameDatabase name
string$schemaDatabase schema
Returns
ConnectionStatus

Definition at line 90 of file PostgresInstaller.php.

References MediaWiki\Installer\ConnectionStatus\setDB().

◆ preInstall()

MediaWiki\Installer\PostgresInstaller::preInstall ( )

Allow DB installers a chance to make last-minute changes before installation occurs.

This happens before setupDatabase() or createTables() is called, but long after the constructor. Helpful for things like modifying setup steps :)

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 292 of file PostgresInstaller.php.

◆ preUpgrade()

MediaWiki\Installer\PostgresInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 407 of file PostgresInstaller.php.

References $wgDBpassword, and $wgDBuser.

◆ setupDatabase()

MediaWiki\Installer\PostgresInstaller::setupDatabase ( )

Create the database and return a Status object indicating success or failure.

Returns
Status

Reimplemented from MediaWiki\Installer\DatabaseInstaller.

Definition at line 313 of file PostgresInstaller.php.

◆ setupPLpgSQL()

MediaWiki\Installer\PostgresInstaller::setupPLpgSQL ( )

Definition at line 424 of file PostgresInstaller.php.

◆ setupSchema()

MediaWiki\Installer\PostgresInstaller::setupSchema ( )

Definition at line 332 of file PostgresInstaller.php.

◆ setupUser()

MediaWiki\Installer\PostgresInstaller::setupUser ( )

Member Data Documentation

◆ $globalNames

MediaWiki\Installer\PostgresInstaller::$globalNames
protected
Initial value:
= [
'wgDBserver',
'wgDBport',
'wgDBname',
'wgDBuser',
'wgDBpassword',
'wgDBssl',
'wgDBmwschema',
]

Definition at line 44 of file PostgresInstaller.php.

◆ $internalDefaults

MediaWiki\Installer\PostgresInstaller::$internalDefaults
protected
Initial value:
= [
'_InstallUser' => 'postgres',
]

Definition at line 55 of file PostgresInstaller.php.

◆ $maxRoleSearchDepth

int MediaWiki\Installer\PostgresInstaller::$maxRoleSearchDepth = 5

Definition at line 64 of file PostgresInstaller.php.

◆ $minimumVersion

MediaWiki\Installer\PostgresInstaller::$minimumVersion = '10'
static

Definition at line 60 of file PostgresInstaller.php.

◆ $notMinimumVersionMessage

MediaWiki\Installer\PostgresInstaller::$notMinimumVersionMessage = 'config-postgres-old'
staticprotected

Definition at line 62 of file PostgresInstaller.php.


The documentation for this class was generated from the following file: