MediaWiki REL1_40
DatabaseInstaller Class Reference

Base class for DBMS-specific installation helper classes. More...

Inherited by MysqlInstaller, PostgresInstaller, and SqliteInstaller.

Collaboration diagram for DatabaseInstaller:

Public Member Functions

 __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.
 
 createManualTables ()
 Create database tables from scratch.
 
 createTables ()
 Create database tables from scratch from the automatically generated file.
 
 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.
 
 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.
 
 getGeneratedSchemaPath ( $db)
 Return a path to the DBMS-specific automatically generated schema file.
 
 getGlobalDefaults ()
 Get a name=>value map of MW configuration globals for the default values.
 
 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.
 
 getLocalSettings ()
 Get the DBMS-specific options for LocalSettings.php generation.
 
 getName ()
 Return the internal name, e.g.
 
 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.
 
 getSettingsForm ()
 Get HTML for a web form that retrieves settings used for installation.
 
 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.
 
 isCompiled ()
 
 needsUpgrade ()
 Determine whether an existing installation of MediaWiki is present in the configured administrative connection.
 
 openConnection ()
 Open a connection to the database using the administrative user/password currently defined in the session, without any caching.
 
 outputHandler ( $string)
 
 populateInterwikiTable ()
 Common function for databases that don't understand the MySQLish syntax of interwiki.list.
 
 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.
 
 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.
 
 submitConnectForm ()
 Set variables based on the request array, assuming it was submitted via the form returned by getConnectForm().
 
 submitInstallUserBox ()
 Submit a standard install user fieldset.
 
 submitSettingsForm ()
 Set variables based on the request array, assuming it was submitted via the form return by getSettingsForm().
 
 submitWebUserBox ()
 Submit the form from getWebUserBox().
 

Static Public Member Functions

static meetsMinimumRequirement (IDatabase $conn)
 Whether the provided version meets the necessary requirements for this type.
 

Public Attributes

Database $db = null
 The database connection.
 
WebInstaller $parent
 The Installer object.
 

Static Public Attributes

static string $minimumVersion
 Set by subclasses.
 

Protected Member Functions

 selectDatabase (Database $conn, string $database)
 

Static Protected Member Functions

static checkExtension ( $name)
 Convenience function.
 

Protected Attributes

array $globalNames = []
 Array of MW configuration globals this class uses.
 
array $internalDefaults = []
 Internal variables for installation.
 

Static Protected Attributes

static string $notMinimumVersionMessage
 Set by subclasses.
 

Detailed Description

Base class for DBMS-specific installation helper classes.

Stability: stable
to extend
Since
1.17

Definition at line 40 of file DatabaseInstaller.php.

Constructor & Destructor Documentation

◆ __construct()

DatabaseInstaller::__construct ( $parent)

Construct and initialise parent.

This is typically only called from Installer::getDBInstaller()

Stability: stable
to call
Parameters
WebInstaller$parent

Definition at line 475 of file DatabaseInstaller.php.

References $parent.

Member Function Documentation

◆ checkExtension()

static DatabaseInstaller::checkExtension ( $name)
staticprotected

Convenience function.

Check if a named extension is present.

Parameters
string$name
Returns
bool

Definition at line 486 of file DatabaseInstaller.php.

Referenced by MysqlInstaller\isCompiled(), PostgresInstaller\isCompiled(), and SqliteInstaller\isCompiled().

◆ checkPrerequisites()

DatabaseInstaller::checkPrerequisites ( )

Checks for installation prerequisites other than those checked by isCompiled()

Stability: stable
to override
Since
1.19
Returns
Status

Reimplemented in SqliteInstaller.

Definition at line 114 of file DatabaseInstaller.php.

◆ createExtensionTables()

DatabaseInstaller::createExtensionTables ( )

Create the tables for each extension the user enabled.

Stability: stable
to override
Returns
Status

Definition at line 342 of file DatabaseInstaller.php.

References getConnection().

◆ createManualTables()

DatabaseInstaller::createManualTables ( )

Create database tables from scratch.

Stability: stable
to override
Returns
Status

Reimplemented in PostgresInstaller, and SqliteInstaller.

Definition at line 269 of file DatabaseInstaller.php.

◆ createTables()

DatabaseInstaller::createTables ( )

Create database tables from scratch from the automatically generated file.

Stability: stable
to override
Returns
Status

Reimplemented in PostgresInstaller, and SqliteInstaller.

Definition at line 259 of file DatabaseInstaller.php.

◆ doUpgrade()

DatabaseInstaller::doUpgrade ( )

Perform database upgrades.

Returns
bool

Definition at line 419 of file DatabaseInstaller.php.

References enableLB(), MWException\getText(), and setupSchemaVars().

◆ enableLB()

DatabaseInstaller::enableLB ( )

Set up LBFactory so that wfGetDB() etc.

works. We set up a special LBFactory instance which returns the current installer connection.

Definition at line 399 of file DatabaseInstaller.php.

References getConnection().

Referenced by PostgresInstaller\createTables(), and doUpgrade().

◆ getCheckBox()

DatabaseInstaller::getCheckBox ( $var,
$label,
$attribs = [],
$helpData = "" )

Get a labelled checkbox to configure a local boolean variable.

Parameters
string$var
string$label
array$attribsOptional.
string$helpDataOptional.
Returns
string

Definition at line 615 of file DatabaseInstaller.php.

References getName(), and getVar().

Referenced by getWebUserBox().

◆ getConnectForm()

DatabaseInstaller::getConnectForm ( )
abstract

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 in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

◆ getConnection()

DatabaseInstaller::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 in PostgresInstaller.

Definition at line 190 of file DatabaseInstaller.php.

References DBO_TRX, and openConnection().

Referenced by MysqlInstaller\canCreateAccounts(), createExtensionTables(), enableLB(), MysqlInstaller\getEngines(), needsUpgrade(), populateInterwikiTable(), Installer\populateSiteStats(), MysqlInstaller\preUpgrade(), MysqlInstaller\setupDatabase(), setupSchemaVars(), MysqlInstaller\setupUser(), and MysqlInstaller\submitConnectForm().

◆ getGeneratedSchemaPath()

DatabaseInstaller::getGeneratedSchemaPath ( $db)

Return a path to the DBMS-specific automatically generated schema file.

Stability: stable
to override
Parameters
IDatabase$db
Returns
string

Definition at line 321 of file DatabaseInstaller.php.

References $db.

Referenced by PostgresInstaller\createTables().

◆ getGlobalDefaults()

DatabaseInstaller::getGlobalDefaults ( )

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

Stability: stable
to override
Returns
array
-taint none

Reimplemented in PostgresInstaller, and SqliteInstaller.

Definition at line 506 of file DatabaseInstaller.php.

References getGlobalNames().

Referenced by getVar().

◆ getGlobalNames()

DatabaseInstaller::getGlobalNames ( )

Get an array of MW configuration globals that will be configured by this class.

Stability: stable
to override
Returns
array

Definition at line 465 of file DatabaseInstaller.php.

References $globalNames.

Referenced by getGlobalDefaults().

◆ getInstallUserBox()

DatabaseInstaller::getInstallUserBox ( )

Get a standard install-user fieldset.

Returns
string

Definition at line 694 of file DatabaseInstaller.php.

References getPasswordBox(), getTextBox(), and wfMessage().

Referenced by MysqlInstaller\getConnectForm(), and PostgresInstaller\getConnectForm().

◆ getInternalDefaults()

DatabaseInstaller::getInternalDefaults ( )

Get a name=>value map of internal variables used during installation.

Returns
array

Definition at line 520 of file DatabaseInstaller.php.

References $internalDefaults.

Referenced by getVar().

◆ getLocalSettings()

DatabaseInstaller::getLocalSettings ( )
abstract

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

Returns
string

Reimplemented in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

◆ getName()

DatabaseInstaller::getName ( )
abstract

Return the internal name, e.g.

'mysql', or 'sqlite'.

Reimplemented in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

Referenced by getCheckBox(), getPasswordBox(), getRadioSet(), getReadableName(), getTextBox(), and setVarsFromRequest().

◆ getPasswordBox()

DatabaseInstaller::getPasswordBox ( $var,
$label,
$attribs = [],
$helpData = "" )

Get a labelled password box to configure a local variable.

Implements password hiding.

Parameters
string$var
string$label
array$attribs
string$helpDataHTML
Returns
string HTML
-taint escaped

Definition at line 589 of file DatabaseInstaller.php.

References getName(), and getVar().

Referenced by getInstallUserBox(), and getWebUserBox().

◆ getRadioSet()

DatabaseInstaller::getRadioSet ( $params)

Get a set of labelled radio buttons.

Parameters
array$paramsParameters are: var: The variable to be configured (required) label: The message name for the label (required) itemLabelPrefix: The message name prefix for the item labels (required) values: List of allowed values (required) itemAttribs Array of attribute arrays, outer key is the value name (optional)
Returns
string

Definition at line 641 of file DatabaseInstaller.php.

References getName(), and getVar().

◆ getReadableName()

DatabaseInstaller::getReadableName ( )

Get the internationalised name for this DBMS.

Stability: stable
to override
Returns
string

Definition at line 495 of file DatabaseInstaller.php.

References getName(), and wfMessage().

◆ getSchemaPath()

DatabaseInstaller::getSchemaPath ( $db)

Return a path to the DBMS-specific schema file, otherwise default to tables.sql.

Stability: stable
to override
Parameters
IDatabase$db
Returns
string

Definition at line 310 of file DatabaseInstaller.php.

References $db.

Referenced by PostgresInstaller\createTables().

◆ getSchemaVars()

DatabaseInstaller::getSchemaVars ( )

Override this to provide DBMS-specific schema variables, to be substituted into tables.sql and other schema files.

Stability: stable
to override
Returns
array

Reimplemented in MysqlInstaller.

Definition at line 369 of file DatabaseInstaller.php.

Referenced by setupSchemaVars().

◆ getSettingsForm()

DatabaseInstaller::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 in MysqlInstaller, and PostgresInstaller.

Definition at line 146 of file DatabaseInstaller.php.

◆ getTextBox()

DatabaseInstaller::getTextBox ( $var,
$label,
$attribs = [],
$helpData = "" )

Get a labelled text box to configure a local variable.

Parameters
string$var
string$label
array$attribs
string$helpDataHTML
Returns
string HTML
-taint escaped

Definition at line 561 of file DatabaseInstaller.php.

References getName(), and getVar().

Referenced by MysqlInstaller\getConnectForm(), PostgresInstaller\getConnectForm(), SqliteInstaller\getConnectForm(), getInstallUserBox(), and getWebUserBox().

◆ getUpdateKeysPath()

DatabaseInstaller::getUpdateKeysPath ( $db)

Return a path to the DBMS-specific update key file, otherwise default to update-keys.sql.

Stability: stable
to override
Parameters
IDatabase$db
Returns
string

Definition at line 333 of file DatabaseInstaller.php.

References $db.

◆ getVar()

◆ getWebUserBox()

DatabaseInstaller::getWebUserBox ( $noCreateMsg = false)

Get a standard web-user fieldset.

Parameters
string | false$noCreateMsgMessage to display instead of the creation checkbox. Set this to false to show a creation checkbox (default).
Returns
string

Definition at line 731 of file DatabaseInstaller.php.

References getCheckBox(), getPasswordBox(), getTextBox(), getVar(), and wfMessage().

Referenced by MysqlInstaller\getSettingsForm(), and PostgresInstaller\getSettingsForm().

◆ insertUpdateKeys()

DatabaseInstaller::insertUpdateKeys ( )

Insert update keys into table to prevent running unneeded updates.

Stability: stable
to override
Returns
Status

Definition at line 279 of file DatabaseInstaller.php.

◆ isCompiled()

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

Reimplemented in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

◆ meetsMinimumRequirement()

static DatabaseInstaller::meetsMinimumRequirement ( IDatabase $conn)
static

Whether the provided version meets the necessary requirements for this type.

Parameters
IDatabase$conn
Returns
Status
Since
1.30

Reimplemented in MysqlInstaller.

Definition at line 87 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\IReadableDatabase\getServerVersion().

◆ needsUpgrade()

DatabaseInstaller::needsUpgrade ( )

Determine whether an existing installation of MediaWiki is present in the configured administrative connection.

Returns true if there is such a wiki, false if the database doesn't exist.

Traditionally, this is done by testing for the existence of either the revision table or the cur table.

Stability: stable
to override
Returns
bool

Reimplemented in SqliteInstaller.

Definition at line 670 of file DatabaseInstaller.php.

References getConnection(), getVar(), and selectDatabase().

◆ openConnection()

DatabaseInstaller::openConnection ( )
abstract

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 in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

Referenced by getConnection().

◆ outputHandler()

DatabaseInstaller::outputHandler ( $string)

Definition at line 818 of file DatabaseInstaller.php.

◆ populateInterwikiTable()

DatabaseInstaller::populateInterwikiTable ( )

Common function for databases that don't understand the MySQLish syntax of interwiki.list.

Stability: stable
to override
Returns
Status

Definition at line 781 of file DatabaseInstaller.php.

References $IP, getConnection(), getVar(), and selectDatabase().

◆ preInstall()

DatabaseInstaller::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 in MysqlInstaller, and PostgresInstaller.

Definition at line 450 of file DatabaseInstaller.php.

◆ preUpgrade()

DatabaseInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Stability: stable
to override

Reimplemented in MysqlInstaller, and PostgresInstaller.

Definition at line 457 of file DatabaseInstaller.php.

◆ selectDatabase()

DatabaseInstaller::selectDatabase ( Database $conn,
string $database )
protected

◆ setupDatabase()

DatabaseInstaller::setupDatabase ( )
abstract

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

Returns
Status

Reimplemented in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

◆ setupSchemaVars()

DatabaseInstaller::setupSchemaVars ( )

Set appropriate schema variables in the current database connection.

This should be called after any request data has been imported, but before any write operations to the database.

Stability: stable
to override

Definition at line 381 of file DatabaseInstaller.php.

References getConnection(), and getSchemaVars().

Referenced by doUpgrade(), MysqlInstaller\setupDatabase(), and MysqlInstaller\setupUser().

◆ setVar()

DatabaseInstaller::setVar ( $name,
$value )

◆ setVarsFromRequest()

DatabaseInstaller::setVarsFromRequest ( $varNames)

Convenience function to set variables based on form data.

Assumes that variables containing "password" in the name are (potentially fake) passwords.

Parameters
array$varNames
Returns
array

Definition at line 655 of file DatabaseInstaller.php.

References getName().

Referenced by MysqlInstaller\submitConnectForm(), PostgresInstaller\submitConnectForm(), SqliteInstaller\submitConnectForm(), submitInstallUserBox(), MysqlInstaller\submitSettingsForm(), and submitWebUserBox().

◆ submitConnectForm()

DatabaseInstaller::submitConnectForm ( )
abstract

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 in MysqlInstaller, PostgresInstaller, and SqliteInstaller.

◆ submitInstallUserBox()

DatabaseInstaller::submitInstallUserBox ( )

Submit a standard install user fieldset.

Returns
Status

Definition at line 718 of file DatabaseInstaller.php.

References setVarsFromRequest().

Referenced by MysqlInstaller\submitConnectForm(), and PostgresInstaller\submitConnectForm().

◆ submitSettingsForm()

DatabaseInstaller::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 in MysqlInstaller, and PostgresInstaller.

Definition at line 157 of file DatabaseInstaller.php.

◆ submitWebUserBox()

DatabaseInstaller::submitWebUserBox ( )

Submit the form from getWebUserBox().

Returns
Status

Definition at line 758 of file DatabaseInstaller.php.

References getVar(), setVar(), and setVarsFromRequest().

Referenced by MysqlInstaller\submitSettingsForm(), and PostgresInstaller\submitSettingsForm().

Member Data Documentation

◆ $db

◆ $globalNames

array DatabaseInstaller::$globalNames = []
protected

Array of MW configuration globals this class uses.

Definition at line 78 of file DatabaseInstaller.php.

Referenced by getGlobalNames().

◆ $internalDefaults

array DatabaseInstaller::$internalDefaults = []
protected

Internal variables for installation.

Definition at line 71 of file DatabaseInstaller.php.

Referenced by getInternalDefaults().

◆ $minimumVersion

string DatabaseInstaller::$minimumVersion
static

Set by subclasses.

Definition at line 52 of file DatabaseInstaller.php.

◆ $notMinimumVersionMessage

string DatabaseInstaller::$notMinimumVersionMessage
staticprotected

Set by subclasses.

Definition at line 57 of file DatabaseInstaller.php.

◆ $parent

WebInstaller DatabaseInstaller::$parent

The Installer object.

Definition at line 47 of file DatabaseInstaller.php.

Referenced by __construct().


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