MediaWiki master
MediaWiki\Installer\DatabaseInstaller Class Reference

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

Inherited by MediaWiki\Installer\MysqlInstaller, MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

Collaboration diagram for MediaWiki\Installer\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 getPrimaryDatabase() etc.
 
 getConnectForm (WebInstaller $webInstaller)
 
 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.
 
 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.
 
 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 (WebInstaller $webInstaller)
 
 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.
 
 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()
 

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.
 
Installer $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.

Since
1.17

Definition at line 45 of file DatabaseInstaller.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Installer\DatabaseInstaller::__construct ( $parent)

Construct and initialise parent.

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

Parameters
WebInstaller$parent

Definition at line 422 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$parent.

Member Function Documentation

◆ checkExtension()

static MediaWiki\Installer\DatabaseInstaller::checkExtension ( $name)
staticprotected

Convenience function.

Check if a named extension is present.

Parameters
string$name
Returns
bool

Definition at line 433 of file DatabaseInstaller.php.

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

◆ checkPrerequisites()

MediaWiki\Installer\DatabaseInstaller::checkPrerequisites ( )

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

Since
1.19
Returns
Status

Reimplemented in MediaWiki\Installer\SqliteInstaller.

Definition at line 118 of file DatabaseInstaller.php.

◆ createExtensionTables()

MediaWiki\Installer\DatabaseInstaller::createExtensionTables ( )

Create the tables for each extension the user enabled.

Returns
Status

Definition at line 294 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\enableLB(), MediaWiki\Installer\DatabaseInstaller\getConnection(), and MediaWiki\Installer\DatabaseUpdater\newForDB().

◆ createManualTables()

MediaWiki\Installer\DatabaseInstaller::createManualTables ( )

Create database tables from scratch.

Returns
Status

Reimplemented in MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

Definition at line 226 of file DatabaseInstaller.php.

◆ createTables()

MediaWiki\Installer\DatabaseInstaller::createTables ( )

Create database tables from scratch from the automatically generated file.

Returns
Status

Reimplemented in MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

Definition at line 217 of file DatabaseInstaller.php.

◆ doUpgrade()

MediaWiki\Installer\DatabaseInstaller::doUpgrade ( )

◆ enableLB()

MediaWiki\Installer\DatabaseInstaller::enableLB ( )

Set up LBFactory so that getPrimaryDatabase() etc.

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

Definition at line 348 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getConnection().

Referenced by MediaWiki\Installer\DatabaseInstaller\createExtensionTables(), and MediaWiki\Installer\DatabaseInstaller\doUpgrade().

◆ getConnectForm()

MediaWiki\Installer\DatabaseInstaller::getConnectForm ( WebInstaller $webInstaller)
abstract

◆ getConnection()

MediaWiki\Installer\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.

Returns
ConnectionStatus

Reimplemented in MediaWiki\Installer\PostgresInstaller.

Definition at line 149 of file DatabaseInstaller.php.

References DBO_TRX, and MediaWiki\Installer\DatabaseInstaller\openConnection().

Referenced by MediaWiki\Installer\DatabaseInstaller\createExtensionTables(), MediaWiki\Installer\DatabaseInstaller\enableLB(), MediaWiki\Installer\DatabaseInstaller\needsUpgrade(), MediaWiki\Installer\DatabaseInstaller\populateInterwikiTable(), MediaWiki\Installer\Installer\populateSiteStats(), and MediaWiki\Installer\DatabaseInstaller\setupSchemaVars().

◆ getGeneratedSchemaPath()

MediaWiki\Installer\DatabaseInstaller::getGeneratedSchemaPath ( $db)

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

Parameters
IDatabase$db
Returns
string

Definition at line 275 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$db.

◆ getGlobalDefaults()

MediaWiki\Installer\DatabaseInstaller::getGlobalDefaults ( )

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

Returns
array

Reimplemented in MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

Definition at line 451 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getGlobalNames().

Referenced by MediaWiki\Installer\DatabaseInstaller\getVar().

◆ getGlobalNames()

MediaWiki\Installer\DatabaseInstaller::getGlobalNames ( )

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

Returns
array

Definition at line 413 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$globalNames.

Referenced by MediaWiki\Installer\DatabaseInstaller\getGlobalDefaults().

◆ getInternalDefaults()

MediaWiki\Installer\DatabaseInstaller::getInternalDefaults ( )

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

Returns
array

Definition at line 465 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$internalDefaults.

Referenced by MediaWiki\Installer\DatabaseInstaller\getVar().

◆ getLocalSettings()

MediaWiki\Installer\DatabaseInstaller::getLocalSettings ( )
abstract

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

Returns
string

Reimplemented in MediaWiki\Installer\MysqlInstaller, MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

◆ getName()

MediaWiki\Installer\DatabaseInstaller::getName ( )
abstract

◆ getReadableName()

MediaWiki\Installer\DatabaseInstaller::getReadableName ( )

Get the internationalised name for this DBMS.

Returns
string

Definition at line 441 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getName(), and wfMessage().

◆ getSchemaPath()

MediaWiki\Installer\DatabaseInstaller::getSchemaPath ( $db)

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

Parameters
IDatabase$db
Returns
string

Definition at line 265 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$db.

◆ getSchemaVars()

MediaWiki\Installer\DatabaseInstaller::getSchemaVars ( )

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

Returns
array

Reimplemented in MediaWiki\Installer\MysqlInstaller.

Definition at line 321 of file DatabaseInstaller.php.

Referenced by MediaWiki\Installer\DatabaseInstaller\setupSchemaVars().

◆ getSettingsForm()

MediaWiki\Installer\DatabaseInstaller::getSettingsForm ( WebInstaller $webInstaller)
abstract

◆ getUpdateKeysPath()

MediaWiki\Installer\DatabaseInstaller::getUpdateKeysPath ( $db)

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

Parameters
IDatabase$db
Returns
string

Definition at line 286 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\$db.

◆ getVar()

MediaWiki\Installer\DatabaseInstaller::getVar ( $var,
$default = null )

Get a variable, taking local defaults into account.

Parameters
string$var
mixed | null$default
Returns
mixed

Definition at line 475 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getGlobalDefaults(), and MediaWiki\Installer\DatabaseInstaller\getInternalDefaults().

Referenced by MediaWiki\Installer\DatabaseInstaller\needsUpgrade(), and MediaWiki\Installer\DatabaseInstaller\populateInterwikiTable().

◆ insertUpdateKeys()

MediaWiki\Installer\DatabaseInstaller::insertUpdateKeys ( )

Insert update keys into table to prevent running unneeded updates.

Returns
Status

Definition at line 235 of file DatabaseInstaller.php.

◆ isCompiled()

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

Reimplemented in MediaWiki\Installer\MysqlInstaller, MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

◆ meetsMinimumRequirement()

static MediaWiki\Installer\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 MediaWiki\Installer\MysqlInstaller.

Definition at line 92 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\IReadableDatabase\getServerVersion().

Referenced by MediaWiki\Installer\PostgresConnectForm\submit().

◆ needsUpgrade()

MediaWiki\Installer\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
bool

Reimplemented in MediaWiki\Installer\SqliteInstaller.

Definition at line 510 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getConnection(), MediaWiki\Installer\DatabaseInstaller\getVar(), and MediaWiki\Installer\DatabaseInstaller\selectDatabase().

◆ openConnection()

MediaWiki\Installer\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
ConnectionStatus

Reimplemented in MediaWiki\Installer\MysqlInstaller, MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

Referenced by MediaWiki\Installer\DatabaseInstaller\getConnection().

◆ outputHandler()

MediaWiki\Installer\DatabaseInstaller::outputHandler ( $string)

Definition at line 578 of file DatabaseInstaller.php.

◆ populateInterwikiTable()

MediaWiki\Installer\DatabaseInstaller::populateInterwikiTable ( )

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

Returns
Status

Definition at line 534 of file DatabaseInstaller.php.

References $IP, MediaWiki\Installer\DatabaseInstaller\getConnection(), MediaWiki\Installer\DatabaseInstaller\getVar(), and MediaWiki\Installer\DatabaseInstaller\selectDatabase().

◆ preInstall()

MediaWiki\Installer\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 MediaWiki\Installer\MysqlInstaller, and MediaWiki\Installer\PostgresInstaller.

Definition at line 400 of file DatabaseInstaller.php.

◆ preUpgrade()

MediaWiki\Installer\DatabaseInstaller::preUpgrade ( )

Allow DB installers a chance to make checks before upgrade.

Reimplemented in MediaWiki\Installer\MysqlInstaller, and MediaWiki\Installer\PostgresInstaller.

Definition at line 406 of file DatabaseInstaller.php.

◆ selectDatabase()

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

◆ setupDatabase()

MediaWiki\Installer\DatabaseInstaller::setupDatabase ( )
abstract

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

Returns
Status

Reimplemented in MediaWiki\Installer\MysqlInstaller, MediaWiki\Installer\PostgresInstaller, and MediaWiki\Installer\SqliteInstaller.

◆ setupSchemaVars()

MediaWiki\Installer\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 331 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\getConnection(), and MediaWiki\Installer\DatabaseInstaller\getSchemaVars().

Referenced by MediaWiki\Installer\DatabaseInstaller\doUpgrade().

◆ setVar()

MediaWiki\Installer\DatabaseInstaller::setVar ( $name,
$value )

Convenience alias for $this->parent->setVar()

Parameters
string$name
mixed$value

Definition at line 492 of file DatabaseInstaller.php.

Member Data Documentation

◆ $db

◆ $globalNames

array MediaWiki\Installer\DatabaseInstaller::$globalNames = []
protected

Array of MW configuration globals this class uses.

Definition at line 83 of file DatabaseInstaller.php.

Referenced by MediaWiki\Installer\DatabaseInstaller\getGlobalNames().

◆ $internalDefaults

array MediaWiki\Installer\DatabaseInstaller::$internalDefaults = []
protected

Internal variables for installation.

Definition at line 76 of file DatabaseInstaller.php.

Referenced by MediaWiki\Installer\DatabaseInstaller\getInternalDefaults().

◆ $minimumVersion

string MediaWiki\Installer\DatabaseInstaller::$minimumVersion
static

Set by subclasses.

Definition at line 57 of file DatabaseInstaller.php.

◆ $notMinimumVersionMessage

string MediaWiki\Installer\DatabaseInstaller::$notMinimumVersionMessage
staticprotected

Set by subclasses.

Definition at line 62 of file DatabaseInstaller.php.

◆ $parent

Installer MediaWiki\Installer\DatabaseInstaller::$parent

The Installer object.

Definition at line 52 of file DatabaseInstaller.php.

Referenced by MediaWiki\Installer\DatabaseInstaller\__construct().


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