MediaWiki REL1_34
MysqlInstaller Class Reference

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

Inheritance diagram for MysqlInstaller:
Collaboration diagram for MysqlInstaller:

Public Member Functions

 canCreateAccounts ()
 Return true if the install user can create accounts.
 
 getCharsets ()
 Get a list of character sets that are available and supported.
 
 getConnectForm ()
 
 getEngines ()
 Get a list of storage engines that are available and supported.
 
 getLocalSettings ()
 Get the DBMS-specific options for LocalSettings.php generation.
 
 getName ()
 
 getSchemaVars ()
 Get variables to substitute into tables.sql and the SQL patch files.
 
 getSettingsForm ()
 
 isCompiled ()
 
 openConnection ()
 
 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 ()
 
 setupUser ()
 
 submitConnectForm ()
 Set variables based on the request array, assuming it was submitted via the form returned by getConnectForm().
 
 submitSettingsForm ()
 
- 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.
 
 createTables ()
 Create database tables from scratch.
 
 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.
 
 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.
 
 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.
 
 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 unneded 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.sql.
 
 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

 $supportedEngines = [ 'InnoDB' ]
 
 $webUserPrivs
 
- Public Attributes inherited from DatabaseInstaller
Database $db = null
 The database connection.
 
WebInstaller $parent
 The Installer object.
 

Static Public Attributes

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

Protected Member Functions

 escapeLikeInternal ( $s, $escapeChar='`')
 
 getTableOptions ()
 Return any table options to be applied to all tables that don't override them.
 
 likeToRegex ( $wildcard)
 Convert a wildcard (as used in LIKE) to a regex Slashes are escaped, slash terminators included.
 

Protected Attributes

 $globalNames
 
 $internalDefaults
 
- 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-mysql-old'
 
- Static Protected Attributes inherited from DatabaseInstaller
static string $notMinimumVersionMessage
 Set by subclasses.
 

Private Member Functions

 buildFullUserName ( $name, $host)
 Return a formal 'User'@'Host' username for use in queries.
 
 databaseExists ( $dbName)
 Try to see if a given database exists.
 
 userDefinitelyExists ( $host, $user)
 Try to see if the user account exists.
 

Additional Inherited Members

- Static Public Member Functions inherited from DatabaseInstaller
static meetsMinimumRequirement ( $serverVersion)
 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 MySQL.

Since
1.17

Definition at line 34 of file MysqlInstaller.php.

Member Function Documentation

◆ buildFullUserName()

MysqlInstaller::buildFullUserName ( $name,
$host )
private

Return a formal 'User'@'Host' username for use in queries.

Parameters
string$nameUsername, quotes will be added
string$hostHostname, quotes will be added
Returns
string

Definition at line 577 of file MysqlInstaller.php.

Referenced by setupUser().

◆ canCreateAccounts()

MysqlInstaller::canCreateAccounts ( )

Return true if the install user can create accounts.

Returns
bool

Definition at line 267 of file MysqlInstaller.php.

References $res, DatabaseInstaller\getConnection(), DatabaseInstaller\getVar(), and likeToRegex().

Referenced by getSettingsForm(), and submitSettingsForm().

◆ databaseExists()

MysqlInstaller::databaseExists ( $dbName)
private

Try to see if a given database exists.

Parameters
string$dbNameDatabase name to check
Returns
bool

Definition at line 464 of file MysqlInstaller.php.

Referenced by setupDatabase().

◆ escapeLikeInternal()

MysqlInstaller::escapeLikeInternal ( $s,
$escapeChar = '`' )
protected
Parameters
string$s
string$escapeChar
Returns
string

Definition at line 222 of file MysqlInstaller.php.

References $s.

Referenced by preUpgrade().

◆ getCharsets()

MysqlInstaller::getCharsets ( )

Get a list of character sets that are available and supported.

Returns
array

Definition at line 258 of file MysqlInstaller.php.

Referenced by getSettingsForm(), and submitSettingsForm().

◆ getConnectForm()

MysqlInstaller::getConnectForm ( )
Returns
string

Reimplemented from DatabaseInstaller.

Definition at line 81 of file MysqlInstaller.php.

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

◆ getEngines()

MysqlInstaller::getEngines ( )

Get a list of storage engines that are available and supported.

Returns
array

Definition at line 233 of file MysqlInstaller.php.

References $res, and DatabaseInstaller\getConnection().

Referenced by getSettingsForm(), and submitSettingsForm().

◆ getLocalSettings()

MysqlInstaller::getLocalSettings ( )

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

Returns
string

Reimplemented from DatabaseInstaller.

Definition at line 631 of file MysqlInstaller.php.

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

◆ getName()

MysqlInstaller::getName ( )
Returns
string

Reimplemented from DatabaseInstaller.

Definition at line 67 of file MysqlInstaller.php.

◆ getSchemaVars()

MysqlInstaller::getSchemaVars ( )

Get variables to substitute into tables.sql and the SQL patch files.

Returns
array

Reimplemented from DatabaseInstaller.

Definition at line 622 of file MysqlInstaller.php.

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

◆ getSettingsForm()

MysqlInstaller::getSettingsForm ( )

◆ getTableOptions()

MysqlInstaller::getTableOptions ( )
protected

Return any table options to be applied to all tables that don't override them.

Returns
string

Definition at line 605 of file MysqlInstaller.php.

References DatabaseInstaller\getVar().

Referenced by getLocalSettings(), and getSchemaVars().

◆ isCompiled()

MysqlInstaller::isCompiled ( )
Returns
bool

Reimplemented from DatabaseInstaller.

Definition at line 74 of file MysqlInstaller.php.

References DatabaseInstaller\checkExtension().

◆ likeToRegex()

MysqlInstaller::likeToRegex ( $wildcard)
protected

Convert a wildcard (as used in LIKE) to a regex Slashes are escaped, slash terminators included.

Parameters
string$wildcard
Returns
string

Definition at line 342 of file MysqlInstaller.php.

Referenced by canCreateAccounts().

◆ openConnection()

MysqlInstaller::openConnection ( )
Returns
Status

Reimplemented from DatabaseInstaller.

Definition at line 143 of file MysqlInstaller.php.

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

◆ preInstall()

MysqlInstaller::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 from DatabaseInstaller.

Definition at line 427 of file MysqlInstaller.php.

◆ preUpgrade()

MysqlInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Reimplemented from DatabaseInstaller.

Definition at line 162 of file MysqlInstaller.php.

References $res, $wgDBpassword, $wgDBuser, escapeLikeInternal(), DatabaseInstaller\getConnection(), DatabaseInstaller\getVar(), and DatabaseInstaller\setVar().

◆ setupDatabase()

MysqlInstaller::setupDatabase ( )

◆ setupUser()

◆ submitConnectForm()

MysqlInstaller::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 98 of file MysqlInstaller.php.

References DatabaseInstaller\getConnection(), DatabaseInstaller\setVarsFromRequest(), and DatabaseInstaller\submitInstallUserBox().

◆ submitSettingsForm()

◆ userDefinitelyExists()

MysqlInstaller::userDefinitelyExists ( $host,
$user )
private

Try to see if the user account exists.

Our "superuser" may not have access to mysql.user, so false means "no" or "maybe"

Parameters
string$hostHostname to check
string$userUsername to check
Returns
bool

Definition at line 588 of file MysqlInstaller.php.

References $res.

Referenced by setupUser().

Member Data Documentation

◆ $globalNames

MysqlInstaller::$globalNames
protected
Initial value:
= [
'wgDBserver',
'wgDBname',
'wgDBuser',
'wgDBpassword',
'wgDBprefix',
'wgDBTableOptions',
]

Definition at line 36 of file MysqlInstaller.php.

◆ $internalDefaults

MysqlInstaller::$internalDefaults
protected
Initial value:
= [
'_MysqlEngine' => 'InnoDB',
'_MysqlCharset' => 'binary',
'_InstallUser' => 'root',
]

Definition at line 45 of file MysqlInstaller.php.

◆ $minimumVersion

MysqlInstaller::$minimumVersion = '5.5.8'
static

Definition at line 53 of file MysqlInstaller.php.

◆ $notMinimumVersionMessage

MysqlInstaller::$notMinimumVersionMessage = 'config-mysql-old'
staticprotected

Definition at line 54 of file MysqlInstaller.php.

◆ $supportedEngines

MysqlInstaller::$supportedEngines = [ 'InnoDB' ]

Definition at line 51 of file MysqlInstaller.php.

◆ $webUserPrivs

MysqlInstaller::$webUserPrivs
Initial value:
= [
'DELETE',
'INSERT',
'SELECT',
'UPDATE',
'CREATE TEMPORARY TABLES',
]

Definition at line 56 of file MysqlInstaller.php.


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