MediaWiki  REL1_22
PostgresInstaller Class Reference

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

Inheritance diagram for PostgresInstaller:
Collaboration diagram for PostgresInstaller:

List of all members.

Public Member Functions

 commitChanges ()
 createTables ()
 Create database tables from scratch.
 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.
 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 Attributes

 $maxRoleSearchDepth = 5
 $minimumVersion = '8.3'

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)
 Open a PG connection with given parameters.
 openPgConnection ($type)
 Get a connection of a specific PostgreSQL-specific type.

Protected Attributes

 $globalNames
 Array of MW configuration globals this class uses.
 $internalDefaults
 Internal variables for installation.
 $pgConns = array()

Detailed Description

Class for setting up the MediaWiki database using Postgres.

Since:
1.17

Definition at line 30 of file PostgresInstaller.php.


Member Function Documentation

Definition at line 294 of file PostgresInstaller.php.

References getInstallUserPermissions().

Referenced by getSettingsForm(), and submitSettingsForm().

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

Returns:
bool

Definition at line 389 of file PostgresInstaller.php.

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

Referenced by submitSettingsForm().

Definition at line 513 of file PostgresInstaller.php.

References Status\newGood().

Create database tables from scratch.

Returns:
Status

Reimplemented from DatabaseInstaller.

Definition at line 575 of file PostgresInstaller.php.

References $error, DatabaseInstaller\enableLB(), getConnection(), and DatabaseInstaller\getVar().

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

References array(), Html\closeElement(), Html\element(), DatabaseInstaller\getInstallUserBox(), DatabaseInstaller\getTextBox(), Html\openElement(), text, and wfMessage().

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.

Returns:
Status

Reimplemented from DatabaseInstaller.

Definition at line 129 of file PostgresInstaller.php.

References getPgConnection().

Referenced by createTables().

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

Returns:
String

Reimplemented from DatabaseInstaller.

Definition at line 557 of file PostgresInstaller.php.

References DatabaseInstaller\getVar().

Return the internal name, e.g.

'mysql', or 'sqlite'.

Reimplemented from DatabaseInstaller.

Definition at line 50 of file PostgresInstaller.php.

PostgresInstaller::getPgConnection ( type) [protected]

Get a special type of connection.

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

Definition at line 171 of file PostgresInstaller.php.

References Status\newGood(), and openPgConnection().

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

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.

Returns:
bool

Reimplemented from DatabaseInstaller.

Definition at line 312 of file PostgresInstaller.php.

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

Returns:
bool Returns true if the client library is compiled in.

Reimplemented from DatabaseInstaller.

Definition at line 54 of file PostgresInstaller.php.

References DatabaseInstaller\checkExtension().

PostgresInstaller::isRoleMember ( conn,
targetMember,
group,
maxDepth 
) [protected]

Recursive helper for canCreateObjectsForWebUser().

Parameters:
$connDatabaseBase object
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 415 of file PostgresInstaller.php.

References $res, array(), and as.

Referenced by canCreateObjectsForWebUser().

Definition at line 303 of file PostgresInstaller.php.

References getInstallUserPermissions().

Referenced by canCreateObjectsForWebUser(), and setupUser().

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

References openPgConnection().

PostgresInstaller::openConnectionWithParams ( user,
password,
dbName 
) [protected]

Open a PG connection with given parameters.

Parameters:
string$userUser name
string$passwordPassword
string$dbNameDatabase name
Returns:
Status

Definition at line 149 of file PostgresInstaller.php.

References DatabaseInstaller\$db, $password, $user, DatabaseInstaller\getVar(), and Status\newGood().

Referenced by 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 object. On success, a connection object will be in the value member.

Definition at line 216 of file PostgresInstaller.php.

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

Referenced by getPgConnection(), and openConnection().

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 DatabaseInstaller.

Definition at line 441 of file PostgresInstaller.php.

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

Allow DB installers a chance to make checks before upgrade.

Reimplemented from DatabaseInstaller.

Definition at line 566 of file PostgresInstaller.php.

References DatabaseInstaller\getVar(), and global.

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

Returns:
Status

Reimplemented from DatabaseInstaller.

Definition at line 467 of file PostgresInstaller.php.

References array(), getPgConnection(), DatabaseInstaller\getVar(), and Status\newGood().

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

References array(), getPgConnection(), DatabaseInstaller\getVar(), Status\newFatal(), Status\newGood(), DatabaseInstaller\setVar(), DatabaseInstaller\setVarsFromRequest(), and DatabaseInstaller\submitInstallUserBox().


Member Data Documentation

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

Array of MW configuration globals this class uses.

Reimplemented from DatabaseInstaller.

Definition at line 32 of file PostgresInstaller.php.

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

Internal variables for installation.

Reimplemented from DatabaseInstaller.

Definition at line 41 of file PostgresInstaller.php.

PostgresInstaller::$maxRoleSearchDepth = 5

Definition at line 46 of file PostgresInstaller.php.

PostgresInstaller::$minimumVersion = '8.3'

Definition at line 45 of file PostgresInstaller.php.

PostgresInstaller::$pgConns = array() [protected]

Definition at line 48 of file PostgresInstaller.php.


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