MediaWiki REL1_31
DatabaseUpdater Class Reference

Class for handling database updates. More...

Inheritance diagram for DatabaseUpdater:
Collaboration diagram for DatabaseUpdater:

Public Member Functions

 addExtensionField ( $tableName, $columnName, $sqlPath)
 
 addExtensionIndex ( $tableName, $indexName, $sqlPath)
 
 addExtensionTable ( $tableName, $sqlPath)
 Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension)
 
 addExtensionUpdate (array $update)
 Add a new update coming from an extension.
 
 addPostDatabaseUpdateMaintenance ( $class)
 Add a maintenance script to be run after the database updates are complete.
 
 appendLine ( $line)
 Append a line to the open filehandle.
 
 copyFile ( $filename)
 Append an SQL fragment to the open file handle.
 
 doUpdates (array $what=[ 'core', 'extensions', 'stats'])
 Do all the updates.
 
 dropExtensionField ( $tableName, $columnName, $sqlPath)
 
 dropExtensionIndex ( $tableName, $indexName, $sqlPath)
 Drop an index from an extension table.
 
 dropExtensionTable ( $tableName, $sqlPath)
 
 dropTable ( $table, $patch=false, $fullpath=false)
 If the specified table exists, drop it, or execute the patch if one is provided.
 
 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 Obviously, only use this for updates that occur after the updatelog table was created!
 
 modifyExtensionField ( $tableName, $fieldName, $sqlPath)
 
 modifyExtensionTable ( $tableName, $sqlPath)
 
 modifyField ( $table, $field, $patch, $fullpath=false)
 Modify an existing field.
 
 modifyTable ( $table, $patch, $fullpath=false)
 Modify an existing table, similar to modifyField.
 
 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.
 
 setFileAccess ()
 Set any .htaccess files or equivilent 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 (Database $db, $shared=false, Maintenance $maintenance=null)
 

Protected Member Functions

 __construct (Database &$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.
 
 applyPatch ( $path, $isFullPath=false, $msg=null)
 Applies a SQL patch.
 
 canUseNewUpdatelog ()
 Updatelog was changed in 1.17 to have a ul_value column so we can record more information about what kind of updates we've done (that's what this class does).
 
 checkStats ()
 Check the site_stats table is not properly populated.
 
 disableContentHandlerUseDB ()
 Turns off content handler fields during parts of the upgrade where they aren't available.
 
 doActiveUsersInit ()
 Sets the number of active users in the site_stats table.
 
 doCollationUpdate ()
 Update CategoryLinks collation.
 
 doEnableProfiling ()
 Enable profiling table when it's turned on.
 
 doLogSearchPopulation ()
 Migrate log params to new table and index for searching.
 
 doLogUsertextPopulation ()
 Populates the log_user_text field in the logging table.
 
 doMigrateUserOptions ()
 Migrates user options from the user table blob to user_properties.
 
 doTable ( $name)
 Returns whether updates should be executed on the database table $name.
 
 doUpdateTranscacheField ()
 Updates the timestamps in the transcache table.
 
 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.
 
 enableContentHandlerUseDB ()
 Turns content handler fields back on.
 
 getCoreUpdateList ()
 Get an array of updates to perform on the database.
 
 getExtensionUpdates ()
 Get the list of extension-defined updates.
 
 getOldGlobalUpdates ()
 Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.
 
 migrateActors ()
 Migrate actors to the new 'actor' table.
 
 migrateArchiveText ()
 Migrate ar_text to modern storage.
 
 migrateComments ()
 Migrate comments to the new 'comment' table.
 
 populateArchiveRevId ()
 Populate ar_rev_id, then make it not nullable.
 
 rebuildLocalisationCache ()
 Rebuilds the localisation cache.
 
 renameIndex ( $table, $oldIndex, $newIndex, $skipBothIndexExistWarning, $patch, $fullpath=false)
 Rename an index from an existing table.
 

Protected Attributes

Database $db
 Handle to the database subclass.
 
array $extensionUpdates = []
 List of extension-provided database updates.
 
resource $fileHandle = null
 File handle for SQL output.
 
 $holdContentHandlerUseDB = true
 Hold the value of $wgContentHandlerUseDB during the upgrade.
 
Maintenance $maintenance
 
string[] $postDatabaseUpdateMaintenance
 Scripts to run after database update Should be a subclass of LoggedUpdateMaintenance.
 
 $shared = false
 
bool $skipSchema = false
 Flag specifying whether or not to skip schema (e.g.
 
array $updates = []
 Array of updates to perform on the database.
 
array $updatesSkipped = []
 Array of updates that were skipped.
 

Private Member Functions

 initOldGlobals ()
 Initialize all of the old globals.
 
 loadExtensions ()
 Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook.
 
 runUpdates (array $updates, $passSelf)
 Helper function for doUpdates()
 
 writeSchemaUpdateFile (array $schemaUpdate=[])
 

Detailed Description

Class for handling database updates.

Roughly based off of updaters.inc, with a few improvements :)

Since
1.17

Definition at line 36 of file DatabaseUpdater.php.

Constructor & Destructor Documentation

◆ __construct()

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

Definition at line 114 of file DatabaseUpdater.php.

References $db, $maintenance, $shared, DBO_DDLMODE, initOldGlobals(), loadExtensions(), Maintenance\setDB(), and Wikimedia\Rdbms\Database\setFlag().

Member Function Documentation

◆ addExtensionField()

DatabaseUpdater::addExtensionField ( $tableName,
$columnName,
$sqlPath )
Since
1.19
Parameters
string$tableName
string$columnName
string$sqlPath

Definition at line 272 of file DatabaseUpdater.php.

References true.

◆ addExtensionIndex()

DatabaseUpdater::addExtensionIndex ( $tableName,
$indexName,
$sqlPath )
Since
1.19
Parameters
string$tableName
string$indexName
string$sqlPath

Definition at line 260 of file DatabaseUpdater.php.

References true.

◆ addExtensionTable()

DatabaseUpdater::addExtensionTable ( $tableName,
$sqlPath )

Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension)

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

Definition at line 249 of file DatabaseUpdater.php.

References true.

◆ addExtensionUpdate()

DatabaseUpdater::addExtensionUpdate ( array $update)

Add a new update coming from an extension.

This should be called by extensions while executing the LoadExtensionSchemaUpdates hook.

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 (ie. 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 236 of file DatabaseUpdater.php.

◆ addField()

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

Add a new field to an existing table.

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 741 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ addIndex()

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

Add a new index to an existing table.

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 766 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ addPostDatabaseUpdateMaintenance()

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 379 of file DatabaseUpdater.php.

◆ addTable()

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

Add a new table to the database.

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 718 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ appendLine()

DatabaseUpdater::appendLine ( $line)

Append a line to the open filehandle.

The line is assumed to be a complete SQL statement.

This is used as a callback for sourceLine().

Parameters
string$lineText to append to the file
Returns
bool False to skip actually executing the file
Exceptions
MWException

Definition at line 648 of file DatabaseUpdater.php.

References $line.

◆ applyPatch()

DatabaseUpdater::applyPatch ( $path,
$isFullPath = false,
$msg = null )
protected

Applies a SQL patch.

Parameters
string$pathPath to the patch file
bool$isFullPathWhether to treat $path as a relative or not
string$msgDescription of the patch
Returns
bool False if patch is skipped.

Reimplemented in MssqlUpdater.

Definition at line 665 of file DatabaseUpdater.php.

References copyFile(), output(), and patchPath().

Referenced by addField(), addIndex(), PostgresUpdater\addInterwikiType(), PostgresUpdater\addPgExtIndex(), addTable(), MysqlUpdater\checkBin(), PostgresUpdater\checkIwlPrefix(), PostgresUpdater\checkPageDeletedTrigger(), PostgresUpdater\checkRevUserFkey(), PostgresUpdater\convertArchive2(), OracleUpdater\doAutoIncrementTriggers(), MysqlUpdater\doBacklinkingIndicesUpdate(), MysqlUpdater\doCategorylinksIndicesUpdate(), MysqlUpdater\doClFieldsUpdate(), doEnableProfiling(), MysqlUpdater\doExtendCommentLengths(), MysqlUpdater\doFilearchiveIndicesUpdate(), MysqlUpdater\doFixAncientImagelinks(), OracleUpdater\doFKRenameDeferr(), OracleUpdater\doFunctions17(), MysqlUpdater\doIndexUpdate(), MysqlUpdater\doInterwikiUpdate(), MysqlUpdater\doIwlinksIndexNonUnique(), MysqlUpdater\doLangLinksLengthUpdate(), MysqlUpdater\doMaybeProfilingMemoryUpdate(), OracleUpdater\doNamespaceDefaults(), MysqlUpdater\doNonUniquePlTlIl(), MysqlUpdater\doPagelinksUpdate(), OracleUpdater\doPageRestrictionsPKUKFix(), OracleUpdater\doRebuildDuplicateFunction(), OracleUpdater\doRecentchangesFK2Cascade(), OracleUpdater\doRemoveNotNullEmptyDefaults(), OracleUpdater\doRemoveNotNullEmptyDefaults2(), MysqlUpdater\doRestrictionsUpdate(), MysqlUpdater\doRevisionPageRevIndexNonUnique(), OracleUpdater\doSchemaUpgrade17(), MysqlUpdater\doTemplatelinksUpdate(), MysqlUpdater\doUnsignedSyncronisation(), MysqlUpdater\doUpdateMimeMinorField(), doUpdateTranscacheField(), MysqlUpdater\doUserGroupsUpdate(), MysqlUpdater\doUserNewTalkTimestampNotNull(), MysqlUpdater\doUserUniqueUpdate(), MysqlUpdater\doWatchlistNull(), dropField(), dropIndex(), dropTable(), migrateArchiveText(), modifyField(), modifyTable(), populateArchiveRevId(), PostgresUpdater\rebuildTextSearch(), renameIndex(), PostgresUpdater\renameTable(), SqliteUpdater\sqliteInitialIndexes(), SqliteUpdater\sqliteSetupSearchindex(), and PostgresUpdater\tsearchFixes().

◆ canUseNewUpdatelog()

DatabaseUpdater::canUseNewUpdatelog ( )
protected

Updatelog was changed in 1.17 to have a ul_value column so we can record more information about what kind of updates we've done (that's what this class does).

Pre-1.17 wikis won't have this column, and really old wikis might not even have updatelog at all

Returns
bool

Definition at line 539 of file DatabaseUpdater.php.

Referenced by insertUpdateRow().

◆ checkStats()

DatabaseUpdater::checkStats ( )
protected

Check the site_stats table is not properly populated.

Definition at line 1029 of file DatabaseUpdater.php.

References SiteStatsInit\doAllAndCommit(), and output().

Referenced by doUpdates().

◆ copyFile()

DatabaseUpdater::copyFile ( $filename)

Append an SQL fragment to the open file handle.

Parameters
string$filenameFile name to open

Definition at line 628 of file DatabaseUpdater.php.

Referenced by applyPatch().

◆ disableContentHandlerUseDB()

DatabaseUpdater::disableContentHandlerUseDB ( )
protected

Turns off content handler fields during parts of the upgrade where they aren't available.

Definition at line 1193 of file DatabaseUpdater.php.

References $wgContentHandlerUseDB, and output().

◆ doActiveUsersInit()

DatabaseUpdater::doActiveUsersInit ( )
protected

Sets the number of active users in the site_stats table.

Definition at line 1049 of file DatabaseUpdater.php.

References output().

◆ doCollationUpdate()

DatabaseUpdater::doCollationUpdate ( )
protected

Update CategoryLinks collation.

Definition at line 1115 of file DatabaseUpdater.php.

References $wgCategoryCollation, and output().

◆ doEnableProfiling()

DatabaseUpdater::doEnableProfiling ( )
protected

Enable profiling table when it's turned on.

Definition at line 1151 of file DatabaseUpdater.php.

References $out, $wgProfiler, applyPatch(), and doTable().

◆ doLogSearchPopulation()

DatabaseUpdater::doLogSearchPopulation ( )
protected

Migrate log params to new table and index for searching.

Definition at line 1084 of file DatabaseUpdater.php.

References output(), and updateRowExists().

◆ doLogUsertextPopulation()

DatabaseUpdater::doLogUsertextPopulation ( )
protected

Populates the log_user_text field in the logging table.

Definition at line 1067 of file DatabaseUpdater.php.

References output(), and updateRowExists().

◆ doMigrateUserOptions()

DatabaseUpdater::doMigrateUserOptions ( )
protected

Migrates user options from the user table blob to user_properties.

Definition at line 1140 of file DatabaseUpdater.php.

References output().

◆ doTable()

DatabaseUpdater::doTable ( $name)
protected

Returns whether updates should be executed on the database table $name.

Updates will be prevented if the table is a shared table and it is not specified to run updates on shared tables.

Parameters
string$nameTable name
Returns
bool

Definition at line 552 of file DatabaseUpdater.php.

References $wgSharedDB, $wgSharedTables, and output().

Referenced by addField(), addIndex(), addTable(), MysqlUpdater\checkBin(), doEnableProfiling(), MysqlUpdater\doInterwikiUpdate(), MysqlUpdater\doMaybeProfilingMemoryUpdate(), MysqlUpdater\doRevisionPageRevIndexNonUnique(), MysqlUpdater\doUnsignedSyncronisation(), MysqlUpdater\doUserGroupsUpdate(), MysqlUpdater\doUserNewTalkTimestampNotNull(), MysqlUpdater\doUserUniqueUpdate(), dropField(), dropIndex(), dropTable(), MysqlUpdater\indexHasField(), modifyField(), modifyTable(), and renameIndex().

◆ doUpdates()

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

Do all the updates.

Parameters
array$whatWhat updates to perform

Reimplemented in OracleUpdater.

Definition at line 440 of file DatabaseUpdater.php.

References checkStats(), getCoreUpdateList(), getExtensionUpdates(), getOldGlobalUpdates(), getSchemaVars(), runUpdates(), and writeSchemaUpdateFile().

◆ doUpdateTranscacheField()

DatabaseUpdater::doUpdateTranscacheField ( )
protected

Updates the timestamps in the transcache table.

Returns
bool

Definition at line 1101 of file DatabaseUpdater.php.

References applyPatch(), output(), and updateRowExists().

◆ dropExtensionField()

DatabaseUpdater::dropExtensionField ( $tableName,
$columnName,
$sqlPath )
Since
1.20
Parameters
string$tableName
string$columnName
string$sqlPath

Definition at line 284 of file DatabaseUpdater.php.

References true.

◆ dropExtensionIndex()

DatabaseUpdater::dropExtensionIndex ( $tableName,
$indexName,
$sqlPath )

Drop an index from an extension table.

Since
1.21
Parameters
string$tableNameThe table name
string$indexNameThe index name
string$sqlPathThe path to the SQL change path

Definition at line 297 of file DatabaseUpdater.php.

References true.

◆ dropExtensionTable()

DatabaseUpdater::dropExtensionTable ( $tableName,
$sqlPath )
Since
1.20
Parameters
string$tableName
string$sqlPath

Definition at line 308 of file DatabaseUpdater.php.

References true.

◆ dropField()

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

Drop a field from an existing table.

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 791 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ dropIndex()

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

Drop an index from an existing table.

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 814 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ dropTable()

DatabaseUpdater::dropTable ( $table,
$patch = false,
$fullpath = false )

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

Public

Since
1.20
Parameters
string$tableTable to drop.
string | bool$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 894 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ enableContentHandlerUseDB()

DatabaseUpdater::enableContentHandlerUseDB ( )
protected

Turns content handler fields back on.

Definition at line 1206 of file DatabaseUpdater.php.

References $holdContentHandlerUseDB, $wgContentHandlerUseDB, and output().

◆ getCoreUpdateList()

DatabaseUpdater::getCoreUpdateList ( )
abstractprotected

Get an array of updates to perform on the database.

Should return a multi-dimensional array. The main key is the MediaWiki version (1.12, 1.13...) with the values being arrays of updates, identical to how updaters.inc did it (for now)

Returns
array[]

Reimplemented in MssqlUpdater, MysqlUpdater, OracleUpdater, PostgresUpdater, and SqliteUpdater.

Referenced by doUpdates().

◆ getDB()

DatabaseUpdater::getDB ( )

Get a database connection to run updates.

Returns
Database

Definition at line 203 of file DatabaseUpdater.php.

References $db.

◆ getExtensionUpdates()

DatabaseUpdater::getExtensionUpdates ( )
protected

Get the list of extension-defined updates.

Returns
array

Definition at line 388 of file DatabaseUpdater.php.

References $extensionUpdates.

Referenced by doUpdates().

◆ getOldGlobalUpdates()

DatabaseUpdater::getOldGlobalUpdates ( )
protected

Before 1.17, we used to handle updates via stuff like $wgExtNewTables/Fields/Indexes.

This is nasty :) We refactored a lot of this in 1.17 but we want to remain back-compatible for a while. So load up these old global-based things into our update list.

Returns
array

Reimplemented in PostgresUpdater.

Definition at line 577 of file DatabaseUpdater.php.

References $updates, and true.

Referenced by doUpdates().

◆ getPostDatabaseUpdateMaintenance()

DatabaseUpdater::getPostDatabaseUpdateMaintenance ( )
Since
1.17
Returns
string[]

Definition at line 397 of file DatabaseUpdater.php.

References $postDatabaseUpdateMaintenance.

◆ getSchemaVars()

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

Definition at line 431 of file DatabaseUpdater.php.

Referenced by doUpdates().

◆ initOldGlobals()

DatabaseUpdater::initOldGlobals ( )
private

Initialize all of the old globals.

One day this should all become something much nicer

Definition at line 134 of file DatabaseUpdater.php.

Referenced by __construct().

◆ insertUpdateRow()

DatabaseUpdater::insertUpdateRow ( $key,
$val = null )

Helper function: Add a key to the updatelog table Obviously, only use this for updates that occur after the updatelog table was created!

Parameters
string$keyName of key to insert
string$val[optional] Value to insert along with the key

Definition at line 521 of file DatabaseUpdater.php.

References canUseNewUpdatelog(), and DBO_DDLMODE.

Referenced by modifyField(), modifyTable(), and MssqlUpdater\updateSchema().

◆ loadExtensions()

DatabaseUpdater::loadExtensions ( )
private

Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook.

Definition at line 152 of file DatabaseUpdater.php.

References $queue, $vars, $wgAutoloadClasses, $wgHooks, Installer\getExistingLocalSettings(), and ExtensionRegistry\getInstance().

Referenced by __construct().

◆ migrateActors()

DatabaseUpdater::migrateActors ( )
protected

Migrate actors to the new 'actor' table.

Since
1.31

Definition at line 1239 of file DatabaseUpdater.php.

References $wgActorTableSchemaMigrationStage, MIGRATION_WRITE_NEW, output(), and updateRowExists().

◆ migrateArchiveText()

DatabaseUpdater::migrateArchiveText ( )
protected

Migrate ar_text to modern storage.

Since
1.31

Definition at line 1259 of file DatabaseUpdater.php.

References applyPatch(), and output().

◆ migrateComments()

DatabaseUpdater::migrateComments ( )
protected

Migrate comments to the new 'comment' table.

Since
1.30

Definition at line 1219 of file DatabaseUpdater.php.

References $wgCommentTableSchemaMigrationStage, MIGRATION_WRITE_NEW, output(), and updateRowExists().

◆ modifyExtensionField()

DatabaseUpdater::modifyExtensionField ( $tableName,
$fieldName,
$sqlPath )
Since
1.21
Parameters
string$tableNameThe table name
string$fieldNameThe field to be modified
string$sqlPathThe path to the SQL patch

Definition at line 345 of file DatabaseUpdater.php.

References true.

◆ modifyExtensionTable()

DatabaseUpdater::modifyExtensionTable ( $tableName,
$sqlPath )
Since
1.31
Parameters
string$tableNameThe table name
string$sqlPathThe path to the SQL patch

Definition at line 355 of file DatabaseUpdater.php.

References true.

◆ modifyField()

DatabaseUpdater::modifyField ( $table,
$field,
$patch,
$fullpath = false )

Modify an existing field.

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 925 of file DatabaseUpdater.php.

References applyPatch(), doTable(), insertUpdateRow(), output(), and updateRowExists().

◆ modifyTable()

DatabaseUpdater::modifyTable ( $table,
$patch,
$fullpath = false )

Modify an existing table, similar to modifyField.

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

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 957 of file DatabaseUpdater.php.

References applyPatch(), doTable(), insertUpdateRow(), output(), and updateRowExists().

◆ newForDB()

static DatabaseUpdater::newForDB ( Database $db,
$shared = false,
Maintenance $maintenance = null )
static

◆ output()

DatabaseUpdater::output ( $str)

Output some text.

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

Parameters
string$strText to output

Definition at line 212 of file DatabaseUpdater.php.

References $wgCommandLineMode.

◆ patchPath()

DatabaseUpdater::patchPath ( IDatabase $db,
$patch )

Get the full path of a patch file.

Originally based on archive() from updaters.inc. 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 699 of file DatabaseUpdater.php.

References $db, $IP, and Wikimedia\Rdbms\IDatabase\getType().

Referenced by applyPatch().

◆ populateArchiveRevId()

DatabaseUpdater::populateArchiveRevId ( )
protected

Populate ar_rev_id, then make it not nullable.

Since
1.31

Definition at line 1275 of file DatabaseUpdater.php.

References applyPatch(), and output().

◆ purgeCache()

DatabaseUpdater::purgeCache ( )

Purge various database caches.

Reimplemented in OracleUpdater.

Definition at line 1003 of file DatabaseUpdater.php.

References $wgLocalisationCacheConf, output(), and rebuildLocalisationCache().

◆ rebuildLocalisationCache()

DatabaseUpdater::rebuildLocalisationCache ( )
protected

Rebuilds the localisation cache.

Definition at line 1176 of file DatabaseUpdater.php.

References output().

Referenced by purgeCache().

◆ renameExtensionIndex()

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

Rename an index on an extension table.

Since
1.21
Parameters
string$tableNameThe table name
string$oldIndexNameThe old index name
string$newIndexNameThe new index name
string$sqlPathThe path to the SQL change path
bool$skipBothIndexExistWarningWhether to warn if both the old and the new indexes exist. [facultative; by default, false]

Definition at line 324 of file DatabaseUpdater.php.

References true.

◆ renameIndex()

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

Rename an index from an existing table.

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 the 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 PostgresUpdater.

Definition at line 840 of file DatabaseUpdater.php.

References applyPatch(), doTable(), and output().

◆ runUpdates()

DatabaseUpdater::runUpdates ( array $updates,
$passSelf )
private

Helper function for doUpdates()

Parameters
array$updatesArray of updates to run
bool$passSelfWhether to pass this object we calling external functions

Definition at line 469 of file DatabaseUpdater.php.

References $params, $ret, $updates, $updatesSkipped, and updates().

Referenced by doUpdates().

◆ setFileAccess()

DatabaseUpdater::setFileAccess ( )

Set any .htaccess files or equivilent for storage repos.

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

Definition at line 982 of file DatabaseUpdater.php.

References output(), and RepoGroup\singleton().

◆ tableExists()

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

Definition at line 366 of file DatabaseUpdater.php.

◆ updateRowExists()

DatabaseUpdater::updateRowExists ( $key)

Helper function: check if the given key is present in the updatelog table.

Obviously, only use this for updates that occur after the updatelog table was created!

Parameters
string$keyName of the key to check for
Returns
bool

Definition at line 502 of file DatabaseUpdater.php.

Referenced by MysqlUpdater\doCategoryPopulation(), MysqlUpdater\doClFieldsUpdate(), doLogSearchPopulation(), doLogUsertextPopulation(), MysqlUpdater\doPopulateParentId(), MysqlUpdater\doUpdateMimeMinorField(), doUpdateTranscacheField(), migrateActors(), migrateComments(), modifyField(), modifyTable(), PostgresUpdater\rebuildTextSearch(), SqliteUpdater\sqliteInitialIndexes(), SqliteUpdater\sqliteSetupSearchindex(), and MssqlUpdater\updateSchema().

◆ writeSchemaUpdateFile()

DatabaseUpdater::writeSchemaUpdateFile ( array $schemaUpdate = [])
private
Since
1.21

Writes the schema updates desired to a file for the DB Admin to run.

Parameters
array$schemaUpdate

Definition at line 407 of file DatabaseUpdater.php.

References $updates, and $updatesSkipped.

Referenced by doUpdates().

Member Data Documentation

◆ $db

Database DatabaseUpdater::$db
protected

Handle to the database subclass.

Definition at line 62 of file DatabaseUpdater.php.

Referenced by __construct(), getDB(), newForDB(), and patchPath().

◆ $extensionUpdates

array DatabaseUpdater::$extensionUpdates = []
protected

List of extension-provided database updates.

Definition at line 55 of file DatabaseUpdater.php.

Referenced by getExtensionUpdates().

◆ $fileHandle

resource DatabaseUpdater::$fileHandle = null
protected

File handle for SQL output.

Definition at line 95 of file DatabaseUpdater.php.

◆ $holdContentHandlerUseDB

DatabaseUpdater::$holdContentHandlerUseDB = true
protected

Hold the value of $wgContentHandlerUseDB during the upgrade.

Definition at line 107 of file DatabaseUpdater.php.

Referenced by enableContentHandlerUseDB().

◆ $maintenance

Maintenance DatabaseUpdater::$maintenance
protected

Definition at line 67 of file DatabaseUpdater.php.

Referenced by __construct(), and newForDB().

◆ $postDatabaseUpdateMaintenance

string [] DatabaseUpdater::$postDatabaseUpdateMaintenance
protected
Initial value:
= [
DeleteDefaultMessages::class,
PopulateRevisionLength::class,
PopulateRevisionSha1::class,
PopulateImageSha1::class,
FixExtLinksProtocolRelative::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 75 of file DatabaseUpdater.php.

Referenced by getPostDatabaseUpdateMaintenance().

◆ $shared

DatabaseUpdater::$shared = false
protected

Definition at line 69 of file DatabaseUpdater.php.

Referenced by __construct(), and newForDB().

◆ $skipSchema

bool DatabaseUpdater::$skipSchema = false
protected

Flag specifying whether or not to skip schema (e.g.

SQL-only) updates.

Definition at line 102 of file DatabaseUpdater.php.

◆ $updates

array DatabaseUpdater::$updates = []
protected

Array of updates to perform on the database.

Definition at line 42 of file DatabaseUpdater.php.

Referenced by getOldGlobalUpdates(), PostgresUpdater\getOldGlobalUpdates(), runUpdates(), and writeSchemaUpdateFile().

◆ $updatesSkipped

array DatabaseUpdater::$updatesSkipped = []
protected

Array of updates that were skipped.

Definition at line 49 of file DatabaseUpdater.php.

Referenced by runUpdates(), and writeSchemaUpdateFile().


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