MediaWiki master
MediaWiki\Installer\DatabaseUpdater Class Reference

Class for handling database updates. More...

Inherited by MediaWiki\Installer\MysqlUpdater, MediaWiki\Installer\PostgresUpdater, and MediaWiki\Installer\SqliteUpdater.

Collaboration diagram for MediaWiki\Installer\DatabaseUpdater:

Public Member Functions

 addExtensionField ( $tableName, $columnName, $sqlPath)
 Add a field to an existing extension table.
 
 addExtensionIndex ( $tableName, $indexName, $sqlPath)
 Add an index to an existing extension table.
 
 addExtensionTable ( $tableName, $sqlPath)
 Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension) Intended for use in LoadExtensionSchemaUpdates hook handlers.
 
 addExtensionUpdate (array $update)
 Add a new update coming from an extension.
 
 addExtensionUpdateOnVirtualDomain (array $update)
 Add a new update coming from an extension on virtual domain databases.
 
 addPostDatabaseUpdateMaintenance ( $class)
 Add a maintenance script to be run after the database updates are complete.
 
 doUpdates (array $what=[ 'core', 'extensions', 'stats'])
 Do all the updates.
 
 dropExtensionField ( $tableName, $columnName, $sqlPath)
 Drop a field from an extension table.
 
 dropExtensionIndex ( $tableName, $indexName, $sqlPath)
 Drop an index from an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.
 
 dropExtensionTable ( $tableName, $sqlPath=false)
 Drop an extension table.
 
 fieldExists ( $tableName, $fieldName)
 
 getDB ()
 Get a database connection to run updates.
 
 getPostDatabaseUpdateMaintenance ()
 
 getSchemaVars ()
 Get appropriate schema variables in the current database connection.
 
 insertUpdateRow ( $key, $val=null)
 Helper function: Add a key to the updatelog table.
 
 modifyExtensionField ( $tableName, $fieldName, $sqlPath)
 Modify an existing field in an extension table.
 
 modifyExtensionTable ( $tableName, $sqlPath)
 Modify an existing extension table.
 
 output ( $str)
 Output some text.
 
 patchPath (IDatabase $db, $patch)
 Get the full path of a patch file.
 
 purgeCache ()
 Purge various database caches.
 
 renameExtensionIndex ( $tableName, $oldIndexName, $newIndexName, $sqlPath, $skipBothIndexExistWarning=false)
 Rename an index on an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.
 
 setAutoExtensionHookContainer (HookContainer $hookContainer)
 Set the HookContainer to use for loading extension schema updates.
 
 setFileAccess ()
 Set any .htaccess files or equivalent for storage repos.
 
 tableExists ( $tableName)
 
 updateRowExists ( $key)
 Helper function: check if the given key is present in the updatelog table.
 

Static Public Member Functions

static newForDB (IMaintainableDatabase $db, $shared=false, Maintenance $maintenance=null)
 

Public Attributes

const REPLICATION_WAIT_TIMEOUT = 300
 

Protected Member Functions

 __construct (IMaintainableDatabase &$db, $shared, Maintenance $maintenance=null)
 
 addField ( $table, $field, $patch, $fullpath=false)
 Add a new field to an existing table.
 
 addIndex ( $table, $index, $patch, $fullpath=false)
 Add a new index to an existing table.
 
 addTable ( $name, $patch, $fullpath=false)
 Add a new table to the database.
 
 appendLine ( $line)
 Append a line to the open file handle.
 
 applyPatch ( $path, $isFullPath=false, $msg=null)
 Applies a SQL patch.
 
 checkStats ()
 Check the site_stats table is not properly populated.
 
 copyFile ( $filename)
 Append an SQL fragment to the open file handle.
 
 doCollationUpdate ()
 Update CategoryLinks collation.
 
 doConvertDjvuMetadata ()
 
 doTable ( $name)
 Returns whether updates should be executed on the database table $name.
 
 dropField ( $table, $field, $patch, $fullpath=false)
 Drop a field from an existing table.
 
 dropIndex ( $table, $index, $patch, $fullpath=false)
 Drop an index from an existing table.
 
 dropTable ( $table, $patch=false, $fullpath=false)
 If the specified table exists, drop it, or execute the patch if one is provided.
 
 getCoreUpdateList ()
 Get an array of updates to perform on the database.
 
 getExtensionUpdates ()
 Get the list of extension-defined updates.
 
 ifFieldExists ( $table, $field, $func,... $params)
 Only run a function if the named field exists.
 
 ifTableNotExists ( $table, $func,... $params)
 Only run a function if a table does not exist.
 
 migrateTemplatelinks ()
 
 modifyField ( $table, $field, $patch, $fullpath=false)
 Modify an existing field.
 
 modifyTable ( $table, $patch, $fullpath=false)
 Modify an existing table, similar to modifyField.
 
 rebuildLocalisationCache ()
 Rebuilds the localisation cache.
 
 renameIndex ( $table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath=false)
 Rename an index from an existing table.
 
 runMaintenance ( $class, $script)
 Run a maintenance script.
 

Protected Attributes

HookContainer null $autoExtensionHookContainer
 
IMaintainableDatabase $db
 Handle to the database subclass.
 
array $extensionUpdates = []
 List of extension-provided database updates.
 
array $extensionUpdatesWithVirtualDomains = []
 List of extension-provided database updates on virtual domain dbs.
 
resource null $fileHandle = null
 File handle for SQL output.
 
Maintenance $maintenance
 
string[] $postDatabaseUpdateMaintenance
 Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.
 
 $shared = false
 
bool $skipSchema = false
 Flag specifying whether to skip schema (e.g., SQL-only) updates.
 
array $updates = []
 Array of updates to perform on the database.
 
array $updatesSkipped = []
 Array of updates that were skipped.
 

Detailed Description

Class for handling database updates.

Since
1.17

Definition at line 67 of file DatabaseUpdater.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Installer\DatabaseUpdater::__construct ( IMaintainableDatabase & $db,
$shared,
Maintenance $maintenance = null )
protected
Parameters
IMaintainableDatabase&$dbTo perform updates on
bool$sharedWhether to perform updates on shared tables
Maintenance | null$maintenanceMaintenance object which created us

Definition at line 150 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\$db, MediaWiki\Installer\DatabaseUpdater\$maintenance, MediaWiki\Installer\DatabaseUpdater\$shared, DBO_DDLMODE, Maintenance\setDB(), and Wikimedia\Rdbms\Database\IDatabaseFlags\setFlag().

Member Function Documentation

◆ addExtensionField()

MediaWiki\Installer\DatabaseUpdater::addExtensionField ( $tableName,
$columnName,
$sqlPath )

Add a field to an existing extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.19
Parameters
string$tableName
string$columnName
string$sqlPath

Definition at line 365 of file DatabaseUpdater.php.

◆ addExtensionIndex()

MediaWiki\Installer\DatabaseUpdater::addExtensionIndex ( $tableName,
$indexName,
$sqlPath )

Add an index to an existing extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.19
Parameters
string$tableName
string$indexName
string$sqlPath

Definition at line 351 of file DatabaseUpdater.php.

◆ addExtensionTable()

MediaWiki\Installer\DatabaseUpdater::addExtensionTable ( $tableName,
$sqlPath )

Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension) Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.18
Parameters
string$tableNameName of table to create
string$sqlPathFull path to the schema file

Definition at line 337 of file DatabaseUpdater.php.

◆ addExtensionUpdate()

MediaWiki\Installer\DatabaseUpdater::addExtensionUpdate ( array $update)

Add a new update coming from an extension.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.17
Parameters
array$updateThe update to run. Format is [ $callback, $params... ] $callback is the method to call; either a DatabaseUpdater method name or a callable. Must be serializable (i.e., no anonymous functions allowed). The rest of the parameters (if any) will be passed to the callback. The first parameter passed to the callback is always this object.

Definition at line 310 of file DatabaseUpdater.php.

◆ addExtensionUpdateOnVirtualDomain()

MediaWiki\Installer\DatabaseUpdater::addExtensionUpdateOnVirtualDomain ( array $update)

Add a new update coming from an extension on virtual domain databases.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.42
Parameters
array$updateThe update to run. The format is [ $virtualDomain, $callback, $params... ] similarly to addExtensionUpdate()

Definition at line 323 of file DatabaseUpdater.php.

◆ addField()

MediaWiki\Installer\DatabaseUpdater::addField ( $table,
$field,
$patch,
$fullpath = false )
protected

Add a new field to an existing table.

Note
Code in a LoadExtensionSchemaUpdates handler should use addExtensionField instead!
Parameters
string$tableName of the table to modify
string$fieldName of the new field
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 827 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ addIndex()

MediaWiki\Installer\DatabaseUpdater::addIndex ( $table,
$index,
$patch,
$fullpath = false )
protected

Add a new index to an existing table.

Note
Code in a LoadExtensionSchemaUpdates handler should use addExtensionIndex instead!
Parameters
string$tableName of the table to modify
string$indexName of the new index
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 855 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ addPostDatabaseUpdateMaintenance()

MediaWiki\Installer\DatabaseUpdater::addPostDatabaseUpdateMaintenance ( $class)

Add a maintenance script to be run after the database updates are complete.

Script should subclass LoggedUpdateMaintenance

Since
1.19
Parameters
string$className of a Maintenance subclass

Definition at line 494 of file DatabaseUpdater.php.

◆ addTable()

MediaWiki\Installer\DatabaseUpdater::addTable ( $name,
$patch,
$fullpath = false )
protected

Add a new table to the database.

Note
Code in a LoadExtensionSchemaUpdates handler should use addExtensionTable instead!
Parameters
string$nameName of the new table
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 802 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ appendLine()

MediaWiki\Installer\DatabaseUpdater::appendLine ( $line)
protected

Append a line to the open file handle.

The line is assumed to be a complete SQL statement.

This is used as a callback for sourceLine().

Note
protected since 1.35
Parameters
string$lineText to append to the file
Returns
bool False to skip actually executing the file

Definition at line 729 of file DatabaseUpdater.php.

Referenced by MediaWiki\Installer\DatabaseUpdater\copyFile().

◆ applyPatch()

◆ checkStats()

MediaWiki\Installer\DatabaseUpdater::checkStats ( )
protected

Check the site_stats table is not properly populated.

Definition at line 1177 of file DatabaseUpdater.php.

References MediaWiki\SiteStats\SiteStatsInit\doAllAndCommit(), and MediaWiki\Installer\DatabaseUpdater\output().

Referenced by MediaWiki\Installer\DatabaseUpdater\doUpdates().

◆ copyFile()

MediaWiki\Installer\DatabaseUpdater::copyFile ( $filename)
protected

Append an SQL fragment to the open file handle.

Note
protected since 1.35
Parameters
string$filenameFile name to open

Definition at line 706 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\appendLine().

Referenced by MediaWiki\Installer\DatabaseUpdater\applyPatch().

◆ doCollationUpdate()

MediaWiki\Installer\DatabaseUpdater::doCollationUpdate ( )
protected

◆ doConvertDjvuMetadata()

MediaWiki\Installer\DatabaseUpdater::doConvertDjvuMetadata ( )
protected

◆ doTable()

MediaWiki\Installer\DatabaseUpdater::doTable ( $name)
protected

◆ doUpdates()

MediaWiki\Installer\DatabaseUpdater::doUpdates ( array $what = [ 'core', 'extensions', 'stats' ])

◆ dropExtensionField()

MediaWiki\Installer\DatabaseUpdater::dropExtensionField ( $tableName,
$columnName,
$sqlPath )

Drop a field from an extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.20
Parameters
string$tableName
string$columnName
string$sqlPath

Definition at line 379 of file DatabaseUpdater.php.

◆ dropExtensionIndex()

MediaWiki\Installer\DatabaseUpdater::dropExtensionIndex ( $tableName,
$indexName,
$sqlPath )

Drop an index from an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.21
Parameters
string$tableName
string$indexName
string$sqlPathThe path to the SQL change path

Definition at line 393 of file DatabaseUpdater.php.

◆ dropExtensionTable()

MediaWiki\Installer\DatabaseUpdater::dropExtensionTable ( $tableName,
$sqlPath = false )

Drop an extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.20
Parameters
string$tableName
string | bool$sqlPath

Definition at line 406 of file DatabaseUpdater.php.

◆ dropField()

MediaWiki\Installer\DatabaseUpdater::dropField ( $table,
$field,
$patch,
$fullpath = false )
protected

Drop a field from an existing table.

Note
Code in a LoadExtensionSchemaUpdates handler should use dropExtensionField instead!
Parameters
string$tableName of the table to modify
string$fieldName of the old field
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 883 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ dropIndex()

MediaWiki\Installer\DatabaseUpdater::dropIndex ( $table,
$index,
$patch,
$fullpath = false )
protected

Drop an index from an existing table.

Note
Code in a LoadExtensionSchemaUpdates handler should use dropExtensionIndex instead!
Parameters
string$tableName of the table to modify
string$indexName of the index
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 908 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ dropTable()

MediaWiki\Installer\DatabaseUpdater::dropTable ( $table,
$patch = false,
$fullpath = false )
protected

If the specified table exists, drop it, or execute the patch if one is provided.

Note
Code in a LoadExtensionSchemaUpdates handler should use dropExtensionTable instead!
protected since 1.35
Parameters
string$tableTable to drop.
string | false$patchString of patch file that will drop the table. Default: false.
bool$fullpathWhether $patch is a full path. Default: false.
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 992 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ fieldExists()

MediaWiki\Installer\DatabaseUpdater::fieldExists ( $tableName,
$fieldName )
Since
1.40
Parameters
string$tableName
string$fieldName
Returns
bool

Definition at line 481 of file DatabaseUpdater.php.

◆ getCoreUpdateList()

MediaWiki\Installer\DatabaseUpdater::getCoreUpdateList ( )
abstractprotected

Get an array of updates to perform on the database.

Should return a multidimensional array. The main key is the MediaWiki version (1.12, 1.13...) with the values being arrays of updates.

Returns
array[]

Reimplemented in MediaWiki\Installer\MysqlUpdater, MediaWiki\Installer\PostgresUpdater, and MediaWiki\Installer\SqliteUpdater.

Referenced by MediaWiki\Installer\DatabaseUpdater\doUpdates().

◆ getDB()

MediaWiki\Installer\DatabaseUpdater::getDB ( )

Get a database connection to run updates.

Returns
IMaintainableDatabase

Definition at line 277 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\$db.

◆ getExtensionUpdates()

MediaWiki\Installer\DatabaseUpdater::getExtensionUpdates ( )
protected

Get the list of extension-defined updates.

Returns
array

Definition at line 503 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\$extensionUpdates.

Referenced by MediaWiki\Installer\DatabaseUpdater\doUpdates().

◆ getPostDatabaseUpdateMaintenance()

MediaWiki\Installer\DatabaseUpdater::getPostDatabaseUpdateMaintenance ( )
Since
1.17
Returns
string[]

Definition at line 512 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\$postDatabaseUpdateMaintenance.

◆ getSchemaVars()

MediaWiki\Installer\DatabaseUpdater::getSchemaVars ( )

Get 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. The result should be passed to the DB setSchemaVars() method.

Returns
array
Since
1.28

Reimplemented in MediaWiki\Installer\MysqlUpdater.

Definition at line 543 of file DatabaseUpdater.php.

Referenced by MediaWiki\Installer\DatabaseUpdater\doUpdates().

◆ ifFieldExists()

MediaWiki\Installer\DatabaseUpdater::ifFieldExists ( $table,
$field,
$func,
$params )
protected

Only run a function if the named field exists.

Since
1.35
Parameters
string$tableTable to check. If passed $this, it's assumed to be a call from runUpdates() with $passSelf = true: all other parameters are shifted and $this is prepended to the rest of $params.
string$fieldField to check
string | array | static$funcNormally this is the string naming the method on $this to call. It may also be an array style callable.
mixed...$params Parameters for $func
Returns
mixed Whatever $func returns, or null when skipped.

Definition at line 1325 of file DatabaseUpdater.php.

References $params.

◆ ifTableNotExists()

MediaWiki\Installer\DatabaseUpdater::ifTableNotExists ( $table,
$func,
$params )
protected

Only run a function if a table does not exist.

Since
1.35
Parameters
string$tableTable to check. If passed $this, it's assumed to be a call from runUpdates() with $passSelf = true: all other parameters are shifted and $this is prepended to the rest of $params.
string | array | static$funcNormally this is the string naming the method on $this to call. It may also be an array style callable.
mixed...$params Parameters for $func
Returns
mixed Whatever $func returns, or null when skipped.

Definition at line 1288 of file DatabaseUpdater.php.

References $params.

◆ insertUpdateRow()

MediaWiki\Installer\DatabaseUpdater::insertUpdateRow ( $key,
$val = null )

Helper function: Add a key to the updatelog table.

Note
Extensions must only use this from within callbacks registered with addExtensionUpdate(). In particular, this method must not be called directly from a LoadExtensionSchemaUpdates handler.
Parameters
string$keyName of the key to insert
string | null$val[optional] Value to insert along with the key

Definition at line 651 of file DatabaseUpdater.php.

References DBO_DDLMODE.

Referenced by MediaWiki\Installer\DatabaseUpdater\doCollationUpdate(), MediaWiki\Installer\DatabaseUpdater\doConvertDjvuMetadata(), MediaWiki\Installer\MysqlUpdater\dropDefault(), MediaWiki\Installer\DatabaseUpdater\modifyField(), and MediaWiki\Installer\DatabaseUpdater\modifyTable().

◆ migrateTemplatelinks()

MediaWiki\Installer\DatabaseUpdater::migrateTemplatelinks ( )
protected

◆ modifyExtensionField()

MediaWiki\Installer\DatabaseUpdater::modifyExtensionField ( $tableName,
$fieldName,
$sqlPath )

Modify an existing field in an extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.21
Parameters
string$tableName
string$fieldNameThe field to be modified
string$sqlPathThe path to the SQL patch

Definition at line 447 of file DatabaseUpdater.php.

◆ modifyExtensionTable()

MediaWiki\Installer\DatabaseUpdater::modifyExtensionTable ( $tableName,
$sqlPath )

Modify an existing extension table.

Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.31
Parameters
string$tableName
string$sqlPathThe path to the SQL patch

Definition at line 460 of file DatabaseUpdater.php.

◆ modifyField()

MediaWiki\Installer\DatabaseUpdater::modifyField ( $table,
$field,
$patch,
$fullpath = false )
protected

Modify an existing field.

Note
Code in a LoadExtensionSchemaUpdates handler should use modifyExtensionField instead!
protected since 1.35
Parameters
string$tableName of the table to which the field belongs
string$fieldName of the field to modify
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Definition at line 1028 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), MediaWiki\Installer\DatabaseUpdater\insertUpdateRow(), MediaWiki\Installer\DatabaseUpdater\output(), and MediaWiki\Installer\DatabaseUpdater\updateRowExists().

◆ modifyTable()

MediaWiki\Installer\DatabaseUpdater::modifyTable ( $table,
$patch,
$fullpath = false )
protected

Modify an existing table, similar to modifyField.

Intended for changes that touch more than one column on a table.

Note
Code in a LoadExtensionSchemaUpdates handler should use modifyExtensionTable instead!
protected since 1.35
Parameters
string$tableName of the table to modify
string$patchName of the patch file to apply
string | bool$fullpathWhether to treat $patch path as relative or not, defaults to false
Returns
bool False if this was skipped because of schema changes being skipped

Definition at line 1065 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), MediaWiki\Installer\DatabaseUpdater\insertUpdateRow(), MediaWiki\Installer\DatabaseUpdater\output(), and MediaWiki\Installer\DatabaseUpdater\updateRowExists().

◆ newForDB()

static MediaWiki\Installer\DatabaseUpdater::newForDB ( IMaintainableDatabase $db,
$shared = false,
Maintenance $maintenance = null )
static

◆ output()

MediaWiki\Installer\DatabaseUpdater::output ( $str)

Output some text.

If we're running via the web, escape the text first.

Parameters
string$strText to output

Definition at line 287 of file DatabaseUpdater.php.

References MW_ENTRY_POINT.

Referenced by MediaWiki\Installer\DatabaseUpdater\addField(), MediaWiki\Installer\DatabaseUpdater\addIndex(), MediaWiki\Installer\PostgresUpdater\addPgExtIndex(), MediaWiki\Installer\PostgresUpdater\addPgField(), MediaWiki\Installer\PostgresUpdater\addPgIndex(), MediaWiki\Installer\PostgresUpdater\addSequence(), MediaWiki\Installer\DatabaseUpdater\addTable(), MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\PostgresUpdater\changeField(), MediaWiki\Installer\PostgresUpdater\changeFieldPurgeTable(), MediaWiki\Installer\PostgresUpdater\changeFkeyDeferrable(), MediaWiki\Installer\PostgresUpdater\changeNullableField(), MediaWiki\Installer\PostgresUpdater\changePrimaryKey(), MediaWiki\Installer\PostgresUpdater\checkIndex(), MediaWiki\Installer\DatabaseUpdater\checkStats(), MediaWiki\Installer\DatabaseUpdater\doCollationUpdate(), MediaWiki\Installer\DatabaseUpdater\doConvertDjvuMetadata(), MediaWiki\Installer\MysqlUpdater\doFixIpbAddressUniqueIndex(), MediaWiki\Installer\SqliteUpdater\doFixIpbAddressUniqueIndex(), MediaWiki\Installer\MysqlUpdater\doLanguageLinksLengthSync(), MediaWiki\Installer\DatabaseUpdater\doTable(), MediaWiki\Installer\MysqlUpdater\dropDefault(), MediaWiki\Installer\PostgresUpdater\dropDefault(), MediaWiki\Installer\DatabaseUpdater\dropField(), MediaWiki\Installer\PostgresUpdater\dropFkey(), MediaWiki\Installer\DatabaseUpdater\dropIndex(), MediaWiki\Installer\PostgresUpdater\dropPgField(), MediaWiki\Installer\PostgresUpdater\dropPgIndex(), MediaWiki\Installer\PostgresUpdater\dropSequence(), MediaWiki\Installer\DatabaseUpdater\dropTable(), MediaWiki\Installer\MysqlUpdater\indexHasField(), MediaWiki\Installer\SqliteUpdater\indexHasField(), MediaWiki\Installer\DatabaseUpdater\migrateTemplatelinks(), MediaWiki\Installer\DatabaseUpdater\modifyField(), MediaWiki\Installer\DatabaseUpdater\modifyTable(), MediaWiki\Installer\DatabaseUpdater\purgeCache(), MediaWiki\Installer\DatabaseUpdater\rebuildLocalisationCache(), MediaWiki\Installer\PostgresUpdater\renameIndex(), MediaWiki\Installer\DatabaseUpdater\renameIndex(), MediaWiki\Installer\PostgresUpdater\renameSequence(), MediaWiki\Installer\PostgresUpdater\renameTable(), MediaWiki\Installer\DatabaseUpdater\runMaintenance(), MediaWiki\Installer\MysqlUpdater\setDefault(), MediaWiki\Installer\PostgresUpdater\setDefault(), MediaWiki\Installer\DatabaseUpdater\setFileAccess(), and MediaWiki\Installer\PostgresUpdater\setSequenceOwner().

◆ patchPath()

MediaWiki\Installer\DatabaseUpdater::patchPath ( IDatabase $db,
$patch )

Get the full path of a patch file.

Keep in mind this always returns a patch, as it fails back to MySQL if no DB-specific patch can be found

Parameters
IDatabase$db
string$patchThe name of the patch, like patch-something.sql
Returns
string Full path to patch file

Definition at line 780 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\$db, MediaWiki\MainConfigNames\BaseDirectory, MediaWiki\MediaWikiServices\getInstance(), and Wikimedia\Rdbms\IReadableDatabase\getType().

Referenced by MediaWiki\Installer\DatabaseUpdater\applyPatch().

◆ purgeCache()

◆ rebuildLocalisationCache()

MediaWiki\Installer\DatabaseUpdater::rebuildLocalisationCache ( )
protected

Rebuilds the localisation cache.

Definition at line 1240 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\output().

Referenced by MediaWiki\Installer\DatabaseUpdater\purgeCache().

◆ renameExtensionIndex()

MediaWiki\Installer\DatabaseUpdater::renameExtensionIndex ( $tableName,
$oldIndexName,
$newIndexName,
$sqlPath,
$skipBothIndexExistWarning = false )

Rename an index on an extension table Intended for use in LoadExtensionSchemaUpdates hook handlers.

Since
1.21
Parameters
string$tableName
string$oldIndexName
string$newIndexName
string$sqlPathThe path to the SQL change file
bool$skipBothIndexExistWarningWhether to warn if both the old and the new indexes exist. [facultative; by default, false]

Definition at line 423 of file DatabaseUpdater.php.

◆ renameIndex()

MediaWiki\Installer\DatabaseUpdater::renameIndex ( $table,
$oldIndex,
$newIndex,
$skipBothIndexExistWarning,
$patch,
$fullpath = false )
protected

Rename an index from an existing table.

Note
Code in a LoadExtensionSchemaUpdates handler should use renameExtensionIndex instead!
Parameters
string$tableName of the table to modify
string$oldIndexOld name of the index
string$newIndexNew name of the index
bool$skipBothIndexExistWarningWhether to warn if both the old and new indexes exist.
string$patchPath to the patch file
bool$fullpathWhether to treat $patch path as a relative or not
Returns
bool False if this was skipped because schema changes are skipped

Reimplemented in MediaWiki\Installer\PostgresUpdater.

Definition at line 935 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\applyPatch(), MediaWiki\Installer\DatabaseUpdater\doTable(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ runMaintenance()

MediaWiki\Installer\DatabaseUpdater::runMaintenance ( $class,
$script )
protected

Run a maintenance script.

This should only be used when the maintenance script must run before later updates. If later updates don't depend on the script, add it to DatabaseUpdater::$postDatabaseUpdateMaintenance instead.

The script's execute() method must return true to indicate successful completion, and must return false (or throw an exception) to indicate unsuccessful completion.

Note
Code in a LoadExtensionSchemaUpdates handler should use addExtensionUpdate instead!
protected since 1.35
Since
1.32
Parameters
string$classMaintenance subclass
string$scriptScript path and filename, usually "maintenance/fooBar.php"

Definition at line 1105 of file DatabaseUpdater.php.

References MediaWiki\Installer\DatabaseUpdater\output().

◆ setAutoExtensionHookContainer()

MediaWiki\Installer\DatabaseUpdater::setAutoExtensionHookContainer ( HookContainer $hookContainer)

Set the HookContainer to use for loading extension schema updates.

Access: internal
For use by DatabaseInstaller
Since
1.36
Parameters
HookContainer$hookContainer

Definition at line 268 of file DatabaseUpdater.php.

◆ setFileAccess()

MediaWiki\Installer\DatabaseUpdater::setFileAccess ( )

Set any .htaccess files or equivalent for storage repos.

Some zones (e.g. "temp") used to be public and may have been initialized as such

Definition at line 1120 of file DatabaseUpdater.php.

References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\Installer\DatabaseUpdater\output().

◆ tableExists()

MediaWiki\Installer\DatabaseUpdater::tableExists ( $tableName)
Since
1.20
Parameters
string$tableName
Returns
bool

Definition at line 470 of file DatabaseUpdater.php.

◆ updateRowExists()

MediaWiki\Installer\DatabaseUpdater::updateRowExists ( $key)

Member Data Documentation

◆ $autoExtensionHookContainer

HookContainer null MediaWiki\Installer\DatabaseUpdater::$autoExtensionHookContainer
protected

Definition at line 111 of file DatabaseUpdater.php.

◆ $db

◆ $extensionUpdates

array MediaWiki\Installer\DatabaseUpdater::$extensionUpdates = []
protected

List of extension-provided database updates.

Definition at line 88 of file DatabaseUpdater.php.

Referenced by MediaWiki\Installer\DatabaseUpdater\getExtensionUpdates().

◆ $extensionUpdatesWithVirtualDomains

array MediaWiki\Installer\DatabaseUpdater::$extensionUpdatesWithVirtualDomains = []
protected

List of extension-provided database updates on virtual domain dbs.

Definition at line 94 of file DatabaseUpdater.php.

◆ $fileHandle

resource null MediaWiki\Installer\DatabaseUpdater::$fileHandle = null
protected

File handle for SQL output.

Definition at line 136 of file DatabaseUpdater.php.

◆ $maintenance

Maintenance MediaWiki\Installer\DatabaseUpdater::$maintenance
protected

◆ $postDatabaseUpdateMaintenance

string [] MediaWiki\Installer\DatabaseUpdater::$postDatabaseUpdateMaintenance
protected
Initial value:
= [
DeleteDefaultMessages::class,
PopulateRevisionLength::class,
PopulateRevisionSha1::class,
PopulateImageSha1::class,
PopulateFilearchiveSha1::class,
PopulateBacklinkNamespace::class,
FixDefaultJsonContentPages::class,
CleanupEmptyCategories::class,
AddRFCandPMIDInterwiki::class,
PopulatePPSortKey::class,
PopulateIpChanges::class,
]

Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.

Definition at line 117 of file DatabaseUpdater.php.

Referenced by MediaWiki\Installer\DatabaseUpdater\getPostDatabaseUpdateMaintenance().

◆ $shared

MediaWiki\Installer\DatabaseUpdater::$shared = false
protected

◆ $skipSchema

bool MediaWiki\Installer\DatabaseUpdater::$skipSchema = false
protected

Flag specifying whether to skip schema (e.g., SQL-only) updates.

Definition at line 143 of file DatabaseUpdater.php.

◆ $updates

array MediaWiki\Installer\DatabaseUpdater::$updates = []
protected

Array of updates to perform on the database.

Definition at line 75 of file DatabaseUpdater.php.

◆ $updatesSkipped

array MediaWiki\Installer\DatabaseUpdater::$updatesSkipped = []
protected

Array of updates that were skipped.

Definition at line 82 of file DatabaseUpdater.php.

◆ REPLICATION_WAIT_TIMEOUT

const MediaWiki\Installer\DatabaseUpdater::REPLICATION_WAIT_TIMEOUT = 300

Definition at line 68 of file DatabaseUpdater.php.


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