MediaWiki REL1_41
PostgresInstaller Class Reference

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

Inherits DatabaseInstaller.

Collaboration diagram for PostgresInstaller:

Public Member Functions

 commitChanges ()
 
 createManualTables ()
 Create database tables from scratch.
 
 createTables ()
 Create database tables from scratch from the automatically generated file.
 
 getConnectForm ()
 Get HTML for a web form that configures this database.
 
 getConnection ()
 Connect to the database using the administrative user/password currently defined in the session.
 
 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 ()
 Get HTML for a web form that retrieves settings used for installation.
 
 isCompiled ()
 
 openConnection ()
 Open a connection to the database using the administrative user/password currently defined in the session, without any caching.
 
 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 ()
 
 submitConnectForm ()
 Set variables based on the request array, assuming it was submitted via the form returned by getConnectForm().
 
 submitSettingsForm ()
 Set variables based on the request array, assuming it was submitted via the form return by getSettingsForm().
 
- Public Member Functions inherited from 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.
 
 doUpgrade ()
 Perform database upgrades.
 
 enableLB ()
 Set up LBFactory so that wfGetDB() etc.
 
 getCheckBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled checkbox to configure a local boolean variable.
 
 getGeneratedSchemaPath ( $db)
 Return a path to the DBMS-specific automatically generated schema file.
 
 getGlobalNames ()
 Get an array of MW configuration globals that will be configured by this class.
 
 getInstallUserBox ()
 Get a standard install-user fieldset.
 
 getInternalDefaults ()
 Get a name=>value map of internal variables used during installation.
 
 getPasswordBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled password box to configure a local variable.
 
 getRadioSet ( $params)
 Get a set of labelled radio buttons.
 
 getReadableName ()
 Get the internationalised name for this DBMS.
 
 getSchemaPath ( $db)
 Return a path to the DBMS-specific schema file, otherwise default to tables.sql.
 
 getSchemaVars ()
 Override this to provide DBMS-specific schema variables, to be substituted into tables.sql and other schema files.
 
 getTextBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled text box to configure a local variable.
 
 getUpdateKeysPath ( $db)
 Return a path to the DBMS-specific update key file, otherwise default to update-keys.sql.
 
 getVar ( $var, $default=null)
 Get a variable, taking local defaults into account.
 
 getWebUserBox ( $noCreateMsg=false)
 Get a standard web-user fieldset.
 
 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.
 
 outputHandler ( $string)
 
 populateInterwikiTable ()
 Common function for databases that don't understand the MySQLish syntax of interwiki.list.
 
 setupSchemaVars ()
 Set appropriate schema variables in the current database connection.
 
 setVar ( $name, $value)
 Convenience alias for $this->parent->setVar()
 
 setVarsFromRequest ( $varNames)
 Convenience function to set variables based on form data.
 
 submitInstallUserBox ()
 Submit a standard install user fieldset.
 
 submitWebUserBox ()
 Submit the form from getWebUserBox().
 

Public Attributes

 $maxRoleSearchDepth = 5
 
- Public Attributes inherited from DatabaseInstaller
Database $db = null
 The database connection.
 
WebInstaller $parent
 The Installer object.
 

Static Public Attributes

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

Protected Member Functions

 canCreateAccounts ()
 
 canCreateObjectsForWebUser ()
 Returns true if the install user is able to create objects owned by the web user, false otherwise.
 
 getInstallUserPermissions ()
 
 getPgConnection ( $type)
 Get a special type of connection.
 
 isRoleMember ( $conn, $targetMember, $group, $maxDepth)
 Recursive helper for canCreateObjectsForWebUser().
 
 isSuperUser ()
 
 openConnectionWithParams ( $user, $password, $dbName, $schema)
 Open a PG connection with given parameters.
 
 openPgConnection ( $type)
 Get a connection of a specific PostgreSQL-specific type.
 
- Protected Member Functions inherited from DatabaseInstaller
 selectDatabase (Database $conn, string $database)
 

Protected Attributes

 $globalNames
 
 $internalDefaults
 
 $pgConns = []
 
- Protected Attributes inherited from 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 DatabaseInstaller
static string $notMinimumVersionMessage
 Set by subclasses.
 

Additional Inherited Members

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

Detailed Description

Class for setting up the MediaWiki database using Postgres.

Since
1.17

Definition at line 39 of file PostgresInstaller.php.

Member Function Documentation

◆ canCreateAccounts()

PostgresInstaller::canCreateAccounts ( )
protected

Definition at line 319 of file PostgresInstaller.php.

References getInstallUserPermissions().

Referenced by getSettingsForm(), and submitSettingsForm().

◆ canCreateObjectsForWebUser()

PostgresInstaller::canCreateObjectsForWebUser ( )
protected

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

Returns
bool

Definition at line 407 of file PostgresInstaller.php.

References getPgConnection(), DatabaseInstaller\getVar(), isRoleMember(), and isSuperUser().

Referenced by submitSettingsForm().

◆ commitChanges()

PostgresInstaller::commitChanges ( )

Definition at line 533 of file PostgresInstaller.php.

◆ createManualTables()

PostgresInstaller::createManualTables ( )

Create database tables from scratch.

Stability: stable
to override
Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 649 of file PostgresInstaller.php.

◆ createTables()

PostgresInstaller::createTables ( )

Create database tables from scratch from the automatically generated file.

Stability: stable
to override
Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 599 of file PostgresInstaller.php.

References DatabaseInstaller\enableLB(), getConnection(), DatabaseInstaller\getGeneratedSchemaPath(), DatabaseInstaller\getSchemaPath(), and DatabaseInstaller\getVar().

◆ getConnectForm()

PostgresInstaller::getConnectForm ( )

Get HTML for a web form that configures this database.

Configuration at this time should be the minimum needed to connect and test whether install or upgrade is required.

If this is called, $this->parent can be assumed to be a WebInstaller.

Reimplemented from DatabaseInstaller.

Definition at line 69 of file PostgresInstaller.php.

References DatabaseInstaller\getCheckBox(), DatabaseInstaller\getInstallUserBox(), DatabaseInstaller\getTextBox(), and wfMessage().

◆ getConnection()

PostgresInstaller::getConnection ( )

Connect to the database using the administrative user/password currently defined in the session.

Returns a status object. On success, the status object will contain a Database object in its value member.

This will return a cached connection if one is available.

Stability: stable
to override
Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 146 of file PostgresInstaller.php.

References getPgConnection().

Referenced by createTables().

◆ getGlobalDefaults()

PostgresInstaller::getGlobalDefaults ( )

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

Stability: stable
to override
Returns
array
-taint none

Reimplemented from DatabaseInstaller.

Definition at line 654 of file PostgresInstaller.php.

◆ getInstallUserPermissions()

PostgresInstaller::getInstallUserPermissions ( )
protected

Definition at line 302 of file PostgresInstaller.php.

References getPgConnection(), and DatabaseInstaller\getVar().

Referenced by canCreateAccounts(), and isSuperUser().

◆ getLocalSettings()

PostgresInstaller::getLocalSettings ( )

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

Returns
string

Reimplemented from DatabaseInstaller.

Definition at line 579 of file PostgresInstaller.php.

References DatabaseInstaller\getVar().

◆ getName()

PostgresInstaller::getName ( )

Return the internal name, e.g.

'mysql', or 'sqlite'.

Reimplemented from DatabaseInstaller.

Definition at line 61 of file PostgresInstaller.php.

◆ getPgConnection()

PostgresInstaller::getPgConnection ( $type)
protected

Get a special type of connection.

Parameters
string$typeSee openPgConnection() for details.
Returns
Status

Definition at line 192 of file PostgresInstaller.php.

References DBO_TRX, and openPgConnection().

Referenced by canCreateObjectsForWebUser(), getConnection(), getInstallUserPermissions(), setupDatabase(), setupPLpgSQL(), setupSchema(), setupUser(), submitConnectForm(), and submitSettingsForm().

◆ getSettingsForm()

PostgresInstaller::getSettingsForm ( )

Get HTML for a web form that retrieves settings used for installation.

$this->parent can be assumed to be a WebInstaller. If the DB type has no settings beyond those already configured with getConnectForm(), this should return false.

Stability: stable
to override
Returns
string|false

Reimplemented from DatabaseInstaller.

Definition at line 329 of file PostgresInstaller.php.

References canCreateAccounts(), and DatabaseInstaller\getWebUserBox().

◆ isCompiled()

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

Reimplemented from DatabaseInstaller.

Definition at line 65 of file PostgresInstaller.php.

References DatabaseInstaller\checkExtension().

◆ isRoleMember()

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 433 of file PostgresInstaller.php.

References isRoleMember().

Referenced by canCreateObjectsForWebUser(), and isRoleMember().

◆ isSuperUser()

PostgresInstaller::isSuperUser ( )
protected

Definition at line 324 of file PostgresInstaller.php.

References getInstallUserPermissions().

Referenced by canCreateObjectsForWebUser(), and setupUser().

◆ openConnection()

PostgresInstaller::openConnection ( )

Open a connection to the database using the administrative user/password currently defined in the session, without any caching.

Returns a status object. On success, the status object will contain a Database object in its value member.

Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 155 of file PostgresInstaller.php.

References openPgConnection().

◆ openConnectionToAnyDB()

PostgresInstaller::openConnectionToAnyDB ( $user,
$password )

◆ openConnectionWithParams()

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
Status

Definition at line 167 of file PostgresInstaller.php.

References DatabaseInstaller\$db, and DatabaseInstaller\getVar().

Referenced by openPgConnection().

◆ openPgConnection()

PostgresInstaller::openPgConnection ( $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:
  • create-db: A connection for creating DBs, suitable for pre- installation.
  • create-schema: A connection to the new DB, for creating schemas and other similar objects in the new DB.
  • create-tables: A connection with a role suitable for creating tables.
Exceptions
MWException
Returns
Status On success, a connection object will be in the value member.

Definition at line 236 of file PostgresInstaller.php.

References DatabaseInstaller\getVar(), openConnectionToAnyDB(), openConnectionWithParams(), and openPgConnection().

Referenced by getPgConnection(), openConnection(), and openPgConnection().

◆ preInstall()

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 :)

Stability: stable
to override

Reimplemented from DatabaseInstaller.

Definition at line 459 of file PostgresInstaller.php.

References DatabaseInstaller\getVar().

◆ preUpgrade()

PostgresInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Stability: stable
to override

Reimplemented from DatabaseInstaller.

Definition at line 590 of file PostgresInstaller.php.

References $wgDBpassword, $wgDBuser, and DatabaseInstaller\getVar().

◆ setupDatabase()

PostgresInstaller::setupDatabase ( )

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

Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 485 of file PostgresInstaller.php.

References getPgConnection(), and DatabaseInstaller\getVar().

◆ setupPLpgSQL()

PostgresInstaller::setupPLpgSQL ( )

Definition at line 662 of file PostgresInstaller.php.

References getPgConnection(), and DatabaseInstaller\getVar().

◆ setupSchema()

PostgresInstaller::setupSchema ( )

Definition at line 504 of file PostgresInstaller.php.

References getPgConnection(), and DatabaseInstaller\getVar().

◆ setupUser()

PostgresInstaller::setupUser ( )

◆ submitConnectForm()

PostgresInstaller::submitConnectForm ( )

Set variables based on the request array, assuming it was submitted via the form returned by getConnectForm().

Validate the connection settings by attempting to connect with them.

If this is called, $this->parent can be assumed to be a WebInstaller.

Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 96 of file PostgresInstaller.php.

References getPgConnection(), DatabaseInstaller\getVar(), DatabaseInstaller\setVar(), DatabaseInstaller\setVarsFromRequest(), and DatabaseInstaller\submitInstallUserBox().

◆ submitSettingsForm()

PostgresInstaller::submitSettingsForm ( )

Set variables based on the request array, assuming it was submitted via the form return by getSettingsForm().

Stability: stable
to override
Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 340 of file PostgresInstaller.php.

References canCreateAccounts(), canCreateObjectsForWebUser(), getPgConnection(), DatabaseInstaller\getVar(), openConnectionToAnyDB(), DatabaseInstaller\setVar(), and DatabaseInstaller\submitWebUserBox().

Member Data Documentation

◆ $globalNames

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

Definition at line 41 of file PostgresInstaller.php.

◆ $internalDefaults

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

Definition at line 51 of file PostgresInstaller.php.

◆ $maxRoleSearchDepth

PostgresInstaller::$maxRoleSearchDepth = 5

Definition at line 57 of file PostgresInstaller.php.

◆ $minimumVersion

PostgresInstaller::$minimumVersion = '10'
static

Definition at line 55 of file PostgresInstaller.php.

◆ $notMinimumVersionMessage

PostgresInstaller::$notMinimumVersionMessage = 'config-postgres-old'
staticprotected

Definition at line 56 of file PostgresInstaller.php.

◆ $pgConns

PostgresInstaller::$pgConns = []
protected

Definition at line 59 of file PostgresInstaller.php.


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