MediaWiki  1.23.15
DatabaseInstaller Class Reference

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

Inheritance diagram for DatabaseInstaller:
Collaboration diagram for DatabaseInstaller:

Public Member Functions

 __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=array(), $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=array(), $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...
 
 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=array(), $helpData="")
 Get a labelled text box to configure a local variable. More...
 
 getVar ( $var, $default=null)
 Get a variable, taking local defaults into account. More...
 
 getWebUserBox ( $noCreateMsg=false)
 Get a standard web-user fieldset. 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

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

Static Protected Member Functions

static checkExtension ( $name)
 Convenience function. More...
 

Protected Attributes

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

Detailed Description

Base class for DBMS-specific installation helper classes.

Since
1.17

Definition at line 30 of file DatabaseInstaller.php.

Constructor & Destructor Documentation

◆ __construct()

DatabaseInstaller::__construct (   $parent)

Construct and initialise parent.

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

Parameters
$parent

Definition at line 315 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
$name
Returns
bool

Definition at line 326 of file DatabaseInstaller.php.

References $name.

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

◆ checkPrerequisites()

DatabaseInstaller::checkPrerequisites ( )

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

Since
1.19
Returns
Status

Reimplemented in SqliteInstaller.

Definition at line 73 of file DatabaseInstaller.php.

References Status\newGood().

◆ createExtensionTables()

DatabaseInstaller::createExtensionTables ( )

Create the tables for each extension the user enabled.

Returns
Status

Definition at line 203 of file DatabaseInstaller.php.

References array(), getConnection(), and DatabaseUpdater\newForDB().

◆ createTables()

DatabaseInstaller::createTables ( )

Create database tables from scratch.

Returns
Status

Reimplemented in MssqlInstaller, PostgresInstaller, OracleInstaller, and SqliteInstaller.

Definition at line 166 of file DatabaseInstaller.php.

References $error, DBO_DDLMODE, enableLB(), getConnection(), and getVar().

◆ doUpgrade()

DatabaseInstaller::doUpgrade ( )

Perform database upgrades.

Returns
Boolean

Definition at line 268 of file DatabaseInstaller.php.

References $e, $ret, array(), enableLB(), DatabaseUpdater\newForDB(), 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 254 of file DatabaseInstaller.php.

References array(), getConnection(), and LBFactory\setInstance().

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

◆ getCheckBox()

DatabaseInstaller::getCheckBox (   $var,
  $label,
  $attribs = array(),
  $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 451 of file DatabaseInstaller.php.

References $attribs, $name, $value, array(), getName(), and getVar().

Referenced by MssqlInstaller\getSettingsForm(), and 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 SqliteInstaller, MssqlInstaller, MysqlInstaller, OracleInstaller, and PostgresInstaller.

◆ getConnection()

DatabaseInstaller::getConnection ( )

◆ getGlobalDefaults()

DatabaseInstaller::getGlobalDefaults ( )

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

Returns
array

Reimplemented in PostgresInstaller, MssqlInstaller, and SqliteInstaller.

Definition at line 344 of file DatabaseInstaller.php.

References $GLOBALS, array(), as, and getGlobalNames().

Referenced by getVar().

◆ getGlobalNames()

DatabaseInstaller::getGlobalNames ( )

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

Returns
array

Definition at line 306 of file DatabaseInstaller.php.

References $globalNames.

Referenced by getGlobalDefaults().

◆ getInstallUserBox()

DatabaseInstaller::getInstallUserBox ( )

◆ getInternalDefaults()

DatabaseInstaller::getInternalDefaults ( )

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

Returns
array

Definition at line 358 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 MssqlInstaller, MysqlInstaller, PostgresInstaller, OracleInstaller, and SqliteInstaller.

◆ getName()

DatabaseInstaller::getName ( )
abstract

Return the internal name, e.g.

'mysql', or 'sqlite'.

Reimplemented in MssqlInstaller, MysqlInstaller, OracleInstaller, PostgresInstaller, and SqliteInstaller.

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

◆ getPasswordBox()

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

Get a labelled password box to configure a local variable.

Implements password hiding.

Parameters
$varstring
$labelstring
$attribsarray
$helpDatastring
Returns
string

Definition at line 425 of file DatabaseInstaller.php.

References $attribs, $name, $value, array(), getName(), and getVar().

Referenced by MssqlInstaller\getConnectForm(), getInstallUserBox(), MssqlInstaller\getSettingsForm(), and getWebUserBox().

◆ getRadioSet()

DatabaseInstaller::getRadioSet (   $params)

Get a set of labelled radio buttons.

Parameters
$paramsArray: Parameters 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 478 of file DatabaseInstaller.php.

References $params, getName(), and getVar().

Referenced by MssqlInstaller\getConnectForm(), MysqlInstaller\getSettingsForm(), and MssqlInstaller\getSettingsForm().

◆ getReadableName()

DatabaseInstaller::getReadableName ( )

Get the internationalised name for this DBMS.

Returns
String

Definition at line 334 of file DatabaseInstaller.php.

References getName(), and wfMessage().

◆ getSchemaVars()

DatabaseInstaller::getSchemaVars ( )

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

Returns
array

Reimplemented in MssqlInstaller, MysqlInstaller, and OracleInstaller.

Definition at line 227 of file DatabaseInstaller.php.

References array().

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.

Returns
bool

Reimplemented in MssqlInstaller, MysqlInstaller, and PostgresInstaller.

Definition at line 104 of file DatabaseInstaller.php.

◆ getTextBox()

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

Get a labelled text box to configure a local variable.

Parameters
$varstring
$labelstring
$attribsarray
$helpDatastring
Returns
string

Definition at line 398 of file DatabaseInstaller.php.

References $attribs, $name, $value, array(), getName(), and getVar().

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

◆ getVar()

DatabaseInstaller::getVar (   $var,
  $default = null 
)

Get a variable, taking local defaults into account.

Parameters
$varstring
$defaultnull
Returns
mixed

Definition at line 368 of file DatabaseInstaller.php.

References getGlobalDefaults(), and getInternalDefaults().

Referenced by MssqlInstaller\canCreateAccounts(), MysqlInstaller\canCreateAccounts(), PostgresInstaller\canCreateObjectsForWebUser(), createTables(), OracleInstaller\createTables(), PostgresInstaller\createTables(), MssqlInstaller\createTables(), getCheckBox(), OracleInstaller\getConnectForm(), MssqlInstaller\getConnectForm(), PostgresInstaller\getInstallUserPermissions(), SqliteInstaller\getLocalSettings(), OracleInstaller\getLocalSettings(), PostgresInstaller\getLocalSettings(), MysqlInstaller\getLocalSettings(), MssqlInstaller\getLocalSettings(), getPasswordBox(), getRadioSet(), OracleInstaller\getSchemaVars(), MysqlInstaller\getSchemaVars(), MssqlInstaller\getSchemaVars(), MysqlInstaller\getSettingsForm(), MssqlInstaller\getSettingsForm(), MysqlInstaller\getTableOptions(), getTextBox(), getWebUserBox(), SqliteInstaller\needsUpgrade(), OracleInstaller\needsUpgrade(), MysqlInstaller\openConnection(), OracleInstaller\openConnection(), SqliteInstaller\openConnection(), MssqlInstaller\openConnection(), PostgresInstaller\openConnectionToAnyDB(), PostgresInstaller\openConnectionWithParams(), PostgresInstaller\openPgConnection(), OracleInstaller\openSYSDBAConnection(), populateInterwikiTable(), PostgresInstaller\preInstall(), MysqlInstaller\preUpgrade(), MssqlInstaller\preUpgrade(), PostgresInstaller\preUpgrade(), SqliteInstaller\setupDatabase(), MssqlInstaller\setupDatabase(), PostgresInstaller\setupDatabase(), MysqlInstaller\setupDatabase(), PostgresInstaller\setupPLpgSQL(), PostgresInstaller\setupSchema(), OracleInstaller\setupUser(), MssqlInstaller\setupUser(), MysqlInstaller\setupUser(), PostgresInstaller\setupUser(), PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), SqliteInstaller\submitConnectForm(), OracleInstaller\submitInstallUserBox(), PostgresInstaller\submitSettingsForm(), MssqlInstaller\submitSettingsForm(), MysqlInstaller\submitSettingsForm(), and submitWebUserBox().

◆ getWebUserBox()

DatabaseInstaller::getWebUserBox (   $noCreateMsg = false)

Get a standard web-user fieldset.

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

Definition at line 560 of file DatabaseInstaller.php.

References $s, array(), Html\closeElement(), Html\element(), getCheckBox(), getPasswordBox(), getTextBox(), getVar(), Html\openElement(), text, and wfMessage().

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

◆ isCompiled()

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

Reimplemented in MssqlInstaller, MysqlInstaller, OracleInstaller, PostgresInstaller, and SqliteInstaller.

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

Returns
Boolean

Reimplemented in OracleInstaller, and SqliteInstaller.

Definition at line 506 of file DatabaseInstaller.php.

References getConnection().

◆ 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 MssqlInstaller, SqliteInstaller, OracleInstaller, MysqlInstaller, and PostgresInstaller.

Referenced by getConnection().

◆ outputHandler()

DatabaseInstaller::outputHandler (   $string)

Definition at line 646 of file DatabaseInstaller.php.

◆ populateInterwikiTable()

DatabaseInstaller::populateInterwikiTable ( )

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

Returns
Status

Definition at line 609 of file DatabaseInstaller.php.

References $IP, array(), as, file, getConnection(), getVar(), global, Status\newFatal(), Status\newGood(), wfRestoreWarnings(), and wfSuppressWarnings().

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

Reimplemented in MysqlInstaller, MssqlInstaller, PostgresInstaller, and OracleInstaller.

Definition at line 293 of file DatabaseInstaller.php.

◆ preUpgrade()

DatabaseInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Reimplemented in PostgresInstaller, MssqlInstaller, and MysqlInstaller.

Definition at line 299 of file DatabaseInstaller.php.

◆ setupDatabase()

DatabaseInstaller::setupDatabase ( )
abstract

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

Returns
Status

Reimplemented in MysqlInstaller, PostgresInstaller, MssqlInstaller, OracleInstaller, 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.

Definition at line 237 of file DatabaseInstaller.php.

References getConnection(), and getSchemaVars().

Referenced by OracleInstaller\createTables(), doUpgrade(), SqliteInstaller\setupDatabase(), MssqlInstaller\setupDatabase(), MysqlInstaller\setupDatabase(), OracleInstaller\setupUser(), MssqlInstaller\setupUser(), and MysqlInstaller\setupUser().

◆ setVar()

◆ 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
$varNamesArray
Returns
array

Definition at line 492 of file DatabaseInstaller.php.

References getName().

Referenced by PostgresInstaller\submitConnectForm(), OracleInstaller\submitConnectForm(), MysqlInstaller\submitConnectForm(), SqliteInstaller\submitConnectForm(), MssqlInstaller\submitConnectForm(), submitInstallUserBox(), MssqlInstaller\submitSettingsForm(), 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 MssqlInstaller, SqliteInstaller, MysqlInstaller, OracleInstaller, and PostgresInstaller.

◆ submitInstallUserBox()

DatabaseInstaller::submitInstallUserBox ( )

Submit a standard install user fieldset.

Returns
Status

Reimplemented in OracleInstaller.

Definition at line 547 of file DatabaseInstaller.php.

References array(), Status\newGood(), and setVarsFromRequest().

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

◆ submitSettingsForm()

DatabaseInstaller::submitSettingsForm ( )

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

Returns
Status

Reimplemented in MysqlInstaller, MssqlInstaller, and PostgresInstaller.

Definition at line 114 of file DatabaseInstaller.php.

References Status\newGood().

◆ submitWebUserBox()

DatabaseInstaller::submitWebUserBox ( )

Member Data Documentation

◆ $db

◆ $globalNames

array DatabaseInstaller::$globalNames = array()
protected

Array of MW configuration globals this class uses.

Definition at line 56 of file DatabaseInstaller.php.

Referenced by getGlobalNames().

◆ $internalDefaults

array DatabaseInstaller::$internalDefaults = array()
protected

Internal variables for installation.

Definition at line 50 of file DatabaseInstaller.php.

Referenced by getInternalDefaults().

◆ $parent

WebInstaller DatabaseInstaller::$parent

The Installer object.

Todo:
Naming this parent is confusing, 'installer' would be clearer.

Definition at line 38 of file DatabaseInstaller.php.

Referenced by __construct().


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