MediaWiki 1.43.1
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.
 
 createTables ()
 Create database tables from scratch from the automatically generated file.
 
 definitelyGetConnection (string $type)
 Get a connection and unwrap it from its Status object, throwing an exception on failure.
 
 enableLB ()
 
 getConnectForm (WebInstaller $webInstaller)
 
 getConnection ( $type=self::CONN_DONT_KNOW)
 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.
 
 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.
 
 getSchemaVars ()
 Override this to provide DBMS-specific schema variables, to be substituted into tables.sql and other schema files.
 
 getSettingsForm (WebInstaller $webInstaller)
 
 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.
 
 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.
 
 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
 
Installer $parent
 The Installer object.
 
const CONN_CREATE_DATABASE = 'create-database'
 A connection for creating DBs, suitable for pre-installation.
 
const CONN_CREATE_SCHEMA = 'create-schema'
 A connection to the new DB, for creating schemas and other similar objects in the new DB.
 
const CONN_CREATE_TABLES = 'create-tables'
 A connection with a role suitable for creating tables.
 
const CONN_DONT_KNOW = 'dont-know'
 Legacy default connection type.
 

Static Public Attributes

static string $minimumVersion
 Set by subclasses.
 

Protected Member Functions

 changeConnType (Database $conn, &$storedType, $newType)
 Change the type of a connection.
 
 changeConnTypeFromSchemaToTables (Database $conn)
 Change the type of a connection from CONN_CREATE_SCHEMA to CONN_CREATE_TABLES.
 
 openConnection (string $type)
 Open a connection to the database using the administrative user/password currently defined in the session, without any caching.
 
 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 41 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
Installer$parent

Definition at line 427 of file DatabaseInstaller.php.

Member Function Documentation

◆ changeConnType()

MediaWiki\Installer\DatabaseInstaller::changeConnType ( Database $conn,
& $storedType,
$newType )
protected

Change the type of a connection.

CONN_CREATE_DATABASE means the domain is indeterminate and irrelevant, so converting from this type can be done by selecting the domain, and converting to it is a no-op.

CONN_CREATE_SCHEMA means the domain is correct but tables created by PostgreSQL will have the incorrect role. So to convert from this to CONN_CREATE_TABLES, we set the role.

CONN_CREATE_TABLES means a fully-configured connection, suitable for most tasks, so converting from it is a no-op.

Parameters
Database$conn
string&$storedTypeOne of the self::CONN_* constants. An in/out parameter, set to the new type on success. It is set to the "real" new type, reflecting the highest configuration level reached, to avoid unnecessary selectDomain() calls when we need to temporarily give an unconfigured connection.
string$newTypeOne of the self::CONN_* constants
Returns
ConnectionStatus

Definition at line 247 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\Database\selectDomain(), and Wikimedia\Rdbms\Database\setSchemaVars().

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

◆ changeConnTypeFromSchemaToTables()

MediaWiki\Installer\DatabaseInstaller::changeConnTypeFromSchemaToTables ( Database $conn)
protected

Change the type of a connection from CONN_CREATE_SCHEMA to CONN_CREATE_TABLES.

Postgres overrides this.

Parameters
Database$conn
Returns
ConnectionStatus

Reimplemented in MediaWiki\Installer\PostgresInstaller.

Definition at line 279 of file DatabaseInstaller.php.

◆ 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 438 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 143 of file DatabaseInstaller.php.

◆ createExtensionTables()

MediaWiki\Installer\DatabaseInstaller::createExtensionTables ( )

Create the tables for each extension the user enabled.

Returns
Status

Definition at line 364 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseUpdater\newForDB().

◆ createTables()

MediaWiki\Installer\DatabaseInstaller::createTables ( )

Create database tables from scratch from the automatically generated file.

Returns
Status

Reimplemented in MediaWiki\Installer\SqliteInstaller.

Definition at line 310 of file DatabaseInstaller.php.

◆ definitelyGetConnection()

MediaWiki\Installer\DatabaseInstaller::definitelyGetConnection ( string $type)

Get a connection and unwrap it from its Status object, throwing an exception on failure.

Parameters
string$type
Returns
Database

Definition at line 216 of file DatabaseInstaller.php.

◆ enableLB()

MediaWiki\Installer\DatabaseInstaller::enableLB ( )
Deprecated
since 1.43

Definition at line 397 of file DatabaseInstaller.php.

◆ getConnectForm()

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

◆ getConnection()

MediaWiki\Installer\DatabaseInstaller::getConnection ( $type = self::CONN_DONT_KNOW)

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.

Parameters
string$typeOne of the self::CONN_* constants. Using CONN_DONT_KNOW is deprecated and will cause an exception to be thrown in a future release.
Returns
ConnectionStatus

Definition at line 179 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseInstaller\changeConnType(), MediaWiki\Installer\DatabaseInstaller\CONN_CREATE_DATABASE, MediaWiki\Installer\DatabaseInstaller\getSchemaVars(), and MediaWiki\Installer\DatabaseInstaller\openConnection().

Referenced by MediaWiki\Installer\Installer\populateSiteStats().

◆ 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 456 of file DatabaseInstaller.php.

◆ getGlobalNames()

MediaWiki\Installer\DatabaseInstaller::getGlobalNames ( )

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

Returns
array

Definition at line 418 of file DatabaseInstaller.php.

◆ getInternalDefaults()

MediaWiki\Installer\DatabaseInstaller::getInternalDefaults ( )

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

Returns
array

Definition at line 470 of file DatabaseInstaller.php.

◆ 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

Return the internal name, e.g.

'mysql', or 'sqlite'.

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

◆ getReadableName()

MediaWiki\Installer\DatabaseInstaller::getReadableName ( )

Get the internationalised name for this DBMS.

Returns
string

Definition at line 446 of file DatabaseInstaller.php.

References wfMessage().

◆ 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 390 of file DatabaseInstaller.php.

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

◆ getSettingsForm()

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

◆ 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 480 of file DatabaseInstaller.php.

◆ insertUpdateKeys()

MediaWiki\Installer\DatabaseInstaller::insertUpdateKeys ( )

Insert update keys into table to prevent running unneeded updates.

Returns
Status

Definition at line 335 of file DatabaseInstaller.php.

References MediaWiki\Installer\DatabaseUpdater\newForDB().

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

Definition at line 515 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\Database\tableExists().

◆ openConnection()

MediaWiki\Installer\DatabaseInstaller::openConnection ( string $type)
abstractprotected

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.

The database should not be implicitly created.

Parameters
string$typeOne of the self::CONN_* constants, except CONN_DONT_KNOW
Returns
ConnectionStatus

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

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

◆ populateInterwikiTable()

MediaWiki\Installer\DatabaseInstaller::populateInterwikiTable ( )

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

Returns
Status

Definition at line 530 of file DatabaseInstaller.php.

References $IP.

◆ 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 405 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 411 of file DatabaseInstaller.php.

◆ selectDatabase()

MediaWiki\Installer\DatabaseInstaller::selectDatabase ( Database $conn,
string $database )
protected
Parameters
Database$conn
string$database
Returns
bool
Since
1.39

Definition at line 580 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\Database\dbSchema(), Wikimedia\Rdbms\Database\selectDomain(), and Wikimedia\Rdbms\Database\tablePrefix().

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

◆ setVar()

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

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

Parameters
string$name
mixed$value

Definition at line 497 of file DatabaseInstaller.php.

Member Data Documentation

◆ $db

Database MediaWiki\Installer\DatabaseInstaller::$db = null
Deprecated
since 1.43 – use definitelyGetConnection()

Definition at line 89 of file DatabaseInstaller.php.

◆ $globalNames

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

Array of MW configuration globals this class uses.

Definition at line 108 of file DatabaseInstaller.php.

◆ $internalDefaults

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

Internal variables for installation.

Definition at line 101 of file DatabaseInstaller.php.

◆ $minimumVersion

string MediaWiki\Installer\DatabaseInstaller::$minimumVersion
static

Set by subclasses.

Definition at line 78 of file DatabaseInstaller.php.

◆ $notMinimumVersionMessage

string MediaWiki\Installer\DatabaseInstaller::$notMinimumVersionMessage
staticprotected

Set by subclasses.

Definition at line 83 of file DatabaseInstaller.php.

◆ $parent

Installer MediaWiki\Installer\DatabaseInstaller::$parent

The Installer object.

Definition at line 73 of file DatabaseInstaller.php.

◆ CONN_CREATE_DATABASE

const MediaWiki\Installer\DatabaseInstaller::CONN_CREATE_DATABASE = 'create-database'

◆ CONN_CREATE_SCHEMA

const MediaWiki\Installer\DatabaseInstaller::CONN_CREATE_SCHEMA = 'create-schema'

A connection to the new DB, for creating schemas and other similar objects in the new DB.

Definition at line 51 of file DatabaseInstaller.php.

◆ CONN_CREATE_TABLES

const MediaWiki\Installer\DatabaseInstaller::CONN_CREATE_TABLES = 'create-tables'

A connection with a role suitable for creating tables.

Definition at line 56 of file DatabaseInstaller.php.

Referenced by MediaWiki\Installer\WebInstaller\doUpgrade(), and MediaWiki\Installer\Installer\populateSiteStats().

◆ CONN_DONT_KNOW

const MediaWiki\Installer\DatabaseInstaller::CONN_DONT_KNOW = 'dont-know'

Legacy default connection type.

Before MW 1.43, getConnection() with no parameters would return the cached connection. The state (especially the selected domain) would depend on the previously executed install steps. Using this constant tries to reproduce this behaviour.

Deprecated
since 1.43

Definition at line 66 of file DatabaseInstaller.php.


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