MediaWiki master
MediaWiki\Installer\DatabaseInstaller Class Reference

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

Inherits MediaWiki\Installer\Task\ITaskContext.

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()
 
 definitelyGetConnection (string $type)
 Get a connection and unwrap it from its Status object, throwing an exception on failure.
 
 getConfigVar (string $name)
 Get a MediaWiki configuration value for the wiki being created.
 
 getConnectForm (WebInstaller $webInstaller)
 
 getConnection ( $type=self::CONN_DONT_KNOW)
 Connect to the database using the administrative user/password currently defined in the session.
 
 getDbType ()
 Get the selected database type name.
 
 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.
 
 getOption (string $name)
 Get a named installer option.
 
 getProvision (string $name)
 Get the object stored by provide()
 
 getReadableName ()
 Get the internationalised name for this DBMS.
 
 getSchemaVars ()
 Override this to provide DBMS-specific schema variables, to be substituted into the schema files.
 
 getSettingsForm (WebInstaller $webInstaller)
 
 getVar ( $var, $default=null)
 Get a variable, taking local defaults into account.
 
 isCompiled ()
 
 needsUpgrade ()
 Determine whether an existing installation of MediaWiki is present in the configured administrative connection.
 
 preUpgrade ()
 Allow DB installers a chance to make checks before upgrade.
 
 provide (string $name, $value)
 Store an object to be used by a later task.
 
 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

IMaintainableDatabase $db = null
 
Installer $parent
 The Installer object.
 
- Public Attributes inherited from MediaWiki\Installer\Task\ITaskContext
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 (IMaintainableDatabase $conn, &$storedType, $newType)
 Change the type of a connection.
 
 changeConnTypeFromSchemaToTables (IMaintainableDatabase $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.
 

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 40 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 311 of file DatabaseInstaller.php.

Member Function Documentation

◆ changeConnType()

MediaWiki\Installer\DatabaseInstaller::changeConnType ( IMaintainableDatabase $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
IMaintainableDatabase$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 216 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\IReadableDatabase\selectDomain(), and Wikimedia\Rdbms\Platform\ISQLPlatform\setSchemaVars().

◆ changeConnTypeFromSchemaToTables()

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

Change the type of a connection from CONN_CREATE_SCHEMA to CONN_CREATE_TABLES.

Postgres overrides this.

Parameters
IMaintainableDatabase$conn
Returns
ConnectionStatus

Reimplemented in MediaWiki\Installer\PostgresInstaller.

Definition at line 248 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 322 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 120 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
IMaintainableDatabase

Definition at line 185 of file DatabaseInstaller.php.

◆ getConfigVar()

MediaWiki\Installer\DatabaseInstaller::getConfigVar ( string $name)

Get a MediaWiki configuration value for the wiki being created.

The name should not have a "wg" prefix.

Parameters
string$name
Returns
mixed

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 256 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

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 148 of file DatabaseInstaller.php.

References MediaWiki\Installer\Task\ITaskContext\CONN_CREATE_DATABASE.

◆ getDbType()

MediaWiki\Installer\DatabaseInstaller::getDbType ( )

Get the selected database type name.

Returns
string

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 252 of file DatabaseInstaller.php.

◆ 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 340 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 302 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 354 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.

◆ getOption()

MediaWiki\Installer\DatabaseInstaller::getOption ( string $name)

Get a named installer option.

Parameters
string$name
Returns
mixed

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 260 of file DatabaseInstaller.php.

◆ getProvision()

MediaWiki\Installer\DatabaseInstaller::getProvision ( string $name)

Get the object stored by provide()

Parameters
string$name
Returns
mixed

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 268 of file DatabaseInstaller.php.

◆ getReadableName()

MediaWiki\Installer\DatabaseInstaller::getReadableName ( )

Get the internationalised name for this DBMS.

Returns
string

Definition at line 330 of file DatabaseInstaller.php.

References wfMessage().

◆ getSchemaVars()

MediaWiki\Installer\DatabaseInstaller::getSchemaVars ( )

Override this to provide DBMS-specific schema variables, to be substituted into the schema files.

Returns
array

Implements MediaWiki\Installer\Task\ITaskContext.

Reimplemented in MediaWiki\Installer\MysqlInstaller.

Definition at line 288 of file DatabaseInstaller.php.

◆ 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 364 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 94 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 399 of file DatabaseInstaller.php.

References Wikimedia\Rdbms\IMaintainableDatabase\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.

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

◆ provide()

MediaWiki\Installer\DatabaseInstaller::provide ( string $name,
$value )

Store an object to be used by a later task.

Parameters
string$name
mixed$value

Implements MediaWiki\Installer\Task\ITaskContext.

Definition at line 264 of file DatabaseInstaller.php.

◆ setVar()

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

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

Parameters
string$name
mixed$value

Definition at line 381 of file DatabaseInstaller.php.

Member Data Documentation

◆ $db

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

Definition at line 63 of file DatabaseInstaller.php.

◆ $globalNames

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

Array of MW configuration globals this class uses.

Definition at line 82 of file DatabaseInstaller.php.

◆ $internalDefaults

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

Internal variables for installation.

Definition at line 75 of file DatabaseInstaller.php.

◆ $minimumVersion

string MediaWiki\Installer\DatabaseInstaller::$minimumVersion
static

Set by subclasses.

Definition at line 52 of file DatabaseInstaller.php.

◆ $notMinimumVersionMessage

string MediaWiki\Installer\DatabaseInstaller::$notMinimumVersionMessage
staticprotected

Set by subclasses.

Definition at line 57 of file DatabaseInstaller.php.

◆ $parent

Installer MediaWiki\Installer\DatabaseInstaller::$parent

The Installer object.

Definition at line 47 of file DatabaseInstaller.php.


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