MediaWiki  master
PostgresInstaller Class Reference

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

Inheritance diagram for PostgresInstaller:
Collaboration diagram for PostgresInstaller:

Public Member Functions

 commitChanges ()
 
 createTables ()
 
 getConnectForm ()
 
 getConnection ()
 
 getGlobalDefaults ()
 
 getLocalSettings ()
 
 getName ()
 
 getSettingsForm ()
 
 isCompiled ()
 
 openConnection ()
 
 openConnectionToAnyDB ( $user, $password)
 
 preInstall ()
 
 preUpgrade ()
 
 setupDatabase ()
 
 setupPLpgSQL ()
 
 setupSchema ()
 
 setupUser ()
 
 submitConnectForm ()
 
 submitSettingsForm ()
 
- Public Member Functions inherited from DatabaseInstaller
 __construct ( $parent)
 Construct and initialise parent. More...
 
 checkPrerequisites ()
 Checks for installation prerequisites other than those checked by isCompiled() More...
 
 createExtensionTables ()
 Create the tables for each extension the user enabled. More...
 
 createTables ()
 Create database tables from scratch. More...
 
 doUpgrade ()
 Perform database upgrades. More...
 
 enableLB ()
 Set up LBFactory so that wfGetDB() etc. More...
 
 getCheckBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled checkbox to configure a local boolean variable. More...
 
 getConnectForm ()
 Get HTML for a web form that configures this database. More...
 
 getConnection ()
 Connect to the database using the administrative user/password currently defined in the session. More...
 
 getGlobalDefaults ()
 Get a name=>value map of MW configuration globals for the default values. More...
 
 getGlobalNames ()
 Get an array of MW configuration globals that will be configured by this class. More...
 
 getInstallUserBox ()
 Get a standard install-user fieldset. More...
 
 getInternalDefaults ()
 Get a name=>value map of internal variables used during installation. More...
 
 getLocalSettings ()
 Get the DBMS-specific options for LocalSettings.php generation. More...
 
 getName ()
 Return the internal name, e.g. More...
 
 getPasswordBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled password box to configure a local variable. More...
 
 getRadioSet ( $params)
 Get a set of labelled radio buttons. More...
 
 getReadableName ()
 Get the internationalised name for this DBMS. More...
 
 getSchemaPath ( $db)
 Return a path to the DBMS-specific schema file, otherwise default to tables.sql. More...
 
 getSchemaVars ()
 Override this to provide DBMS-specific schema variables, to be substituted into tables.sql and other schema files. More...
 
 getSettingsForm ()
 Get HTML for a web form that retrieves settings used for installation. More...
 
 getTextBox ( $var, $label, $attribs=[], $helpData="")
 Get a labelled text box to configure a local variable. More...
 
 getUpdateKeysPath ( $db)
 Return a path to the DBMS-specific update key file, otherwise default to update-keys.sql. More...
 
 getVar ( $var, $default=null)
 Get a variable, taking local defaults into account. More...
 
 getWebUserBox ( $noCreateMsg=false)
 Get a standard web-user fieldset. More...
 
 insertUpdateKeys ()
 Insert update keys into table to prevent running unneded updates. More...
 
 isCompiled ()
 
 needsUpgrade ()
 Determine whether an existing installation of MediaWiki is present in the configured administrative connection. More...
 
 openConnection ()
 Open a connection to the database using the administrative user/password currently defined in the session, without any caching. More...
 
 outputHandler ( $string)
 
 populateInterwikiTable ()
 Common function for databases that don't understand the MySQLish syntax of interwiki.sql. More...
 
 preInstall ()
 Allow DB installers a chance to make last-minute changes before installation occurs. More...
 
 preUpgrade ()
 Allow DB installers a chance to make checks before upgrade. More...
 
 setupDatabase ()
 Create the database and return a Status object indicating success or failure. More...
 
 setupSchemaVars ()
 Set appropriate schema variables in the current database connection. More...
 
 setVar ( $name, $value)
 Convenience alias for $this->parent->setVar() More...
 
 setVarsFromRequest ( $varNames)
 Convenience function to set variables based on form data. More...
 
 submitConnectForm ()
 Set variables based on the request array, assuming it was submitted via the form returned by getConnectForm(). More...
 
 submitInstallUserBox ()
 Submit a standard install user fieldset. More...
 
 submitSettingsForm ()
 Set variables based on the request array, assuming it was submitted via the form return by getSettingsForm(). More...
 
 submitWebUserBox ()
 Submit the form from getWebUserBox(). More...
 

Public Attributes

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

Static Public Attributes

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

Protected Member Functions

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

Protected Attributes

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

Static Protected Attributes

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

Additional Inherited Members

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

Detailed Description

Class for setting up the MediaWiki database using Postgres.

Since
1.17

Definition at line 35 of file PostgresInstaller.php.

Member Function Documentation

◆ canCreateAccounts()

PostgresInstaller::canCreateAccounts ( )
protected

Definition at line 311 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.

References StatusValue\newGood().

◆ createTables()

PostgresInstaller::createTables ( )

◆ getConnectForm()

◆ getConnection()

PostgresInstaller::getConnection ( )

Definition at line 140 of file PostgresInstaller.php.

References getPgConnection().

Referenced by createTables().

◆ getGlobalDefaults()

PostgresInstaller::getGlobalDefaults ( )

Definition at line 639 of file PostgresInstaller.php.

◆ getInstallUserPermissions()

PostgresInstaller::getInstallUserPermissions ( )
protected

Definition at line 294 of file PostgresInstaller.php.

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

Referenced by canCreateAccounts(), and isSuperUser().

◆ getLocalSettings()

PostgresInstaller::getLocalSettings ( )

Definition at line 579 of file PostgresInstaller.php.

References DatabaseInstaller\getVar().

◆ getName()

PostgresInstaller::getName ( )

Definition at line 56 of file PostgresInstaller.php.

◆ getPgConnection()

PostgresInstaller::getPgConnection (   $type)
protected

◆ getSettingsForm()

PostgresInstaller::getSettingsForm ( )

Definition at line 329 of file PostgresInstaller.php.

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

◆ isCompiled()

PostgresInstaller::isCompiled ( )

Definition at line 60 of file PostgresInstaller.php.

◆ 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 $res.

Referenced by canCreateObjectsForWebUser().

◆ isSuperUser()

PostgresInstaller::isSuperUser ( )
protected

Definition at line 320 of file PostgresInstaller.php.

References getInstallUserPermissions().

Referenced by canCreateObjectsForWebUser(), and setupUser().

◆ openConnection()

PostgresInstaller::openConnection ( )

Definition at line 149 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 161 of file PostgresInstaller.php.

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

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

References $type, DatabaseInstaller\getVar(), openConnectionToAnyDB(), and openConnectionWithParams().

Referenced by getPgConnection(), and openConnection().

◆ preInstall()

PostgresInstaller::preInstall ( )

Definition at line 459 of file PostgresInstaller.php.

References DatabaseInstaller\getVar().

◆ preUpgrade()

PostgresInstaller::preUpgrade ( )

Definition at line 588 of file PostgresInstaller.php.

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

◆ setupDatabase()

PostgresInstaller::setupDatabase ( )

◆ setupPLpgSQL()

PostgresInstaller::setupPLpgSQL ( )

◆ setupSchema()

PostgresInstaller::setupSchema ( )

◆ setupUser()

PostgresInstaller::setupUser ( )

◆ submitConnectForm()

◆ submitSettingsForm()

Member Data Documentation

◆ $globalNames

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

Definition at line 37 of file PostgresInstaller.php.

◆ $internalDefaults

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

Definition at line 46 of file PostgresInstaller.php.

◆ $maxRoleSearchDepth

PostgresInstaller::$maxRoleSearchDepth = 5

Definition at line 52 of file PostgresInstaller.php.

◆ $minimumVersion

PostgresInstaller::$minimumVersion = '9.2'
static

Definition at line 50 of file PostgresInstaller.php.

◆ $notMinimumVersionMessage

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

Definition at line 51 of file PostgresInstaller.php.

◆ $pgConns

PostgresInstaller::$pgConns = []
protected

Definition at line 54 of file PostgresInstaller.php.


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