MediaWiki
REL1_19
|
Class for handling database updates. More...
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. | |
doUpdates ($what=array( 'core', 'extensions', 'purge', 'stats')) | |
Do all the updates. | |
getDB () | |
Get a database connection to run updates. | |
getPostDatabaseUpdateMaintenance () | |
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! | |
modifyField ($table, $field, $patch, $fullpath=false) | |
Modify an existing field. | |
output ($str) | |
Output some text. | |
updateRowExists ($key) | |
Helper function: check if the given key is present in the updatelog table. | |
Static Public Member Functions | |
static | newForDB (&$db, $shared=false, $maintenance=null) |
Protected Member Functions | |
__construct (DatabaseBase &$db, $shared, Maintenance $maintenance=null) | |
Constructor. | |
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) | |
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. | |
doActiveUsersInit () | |
Sets the number of active users in the site_stats table. | |
doCollationUpdate () | |
Update CategoryLinks collation. | |
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. | |
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. | |
dropTable ($table, $patch, $fullpath=false) | |
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. | |
purgeCache () | |
Purge the objectcache table. | |
rebuildLocalisationCache () | |
Rebuilds the localisation cache. | |
setAppliedUpdates ($version, $updates=array()) | |
Protected Attributes | |
$db | |
$extensionUpdates = array() | |
$postDatabaseUpdateMaintenance | |
$shared = false | |
$updates = array() | |
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() |
Class for handling database updates.
Roughly based off of updaters.inc, with a few improvements :)
Definition at line 18 of file DatabaseUpdater.php.
DatabaseUpdater::__construct | ( | DatabaseBase &$ | db, |
$ | shared, | ||
Maintenance $ | maintenance = null |
||
) | [protected] |
Constructor.
$db | DatabaseBase object to perform updates on |
$shared | bool Whether to perform updates on shared tables |
$maintenance | Maintenance Maintenance object which created us |
Definition at line 57 of file DatabaseUpdater.php.
References $db, $maintenance, $shared, initOldGlobals(), loadExtensions(), Maintenance\setDB(), and wfRunHooks().
DatabaseUpdater::addExtensionField | ( | $ | tableName, |
$ | columnName, | ||
$ | sqlPath | ||
) |
$tableName | string |
$columnName | string |
$sqlPath | string |
Definition at line 201 of file DatabaseUpdater.php.
DatabaseUpdater::addExtensionIndex | ( | $ | tableName, |
$ | indexName, | ||
$ | sqlPath | ||
) |
$tableName | string |
$indexName | string |
$sqlPath | string |
Definition at line 189 of file DatabaseUpdater.php.
DatabaseUpdater::addExtensionTable | ( | $ | tableName, |
$ | sqlPath | ||
) |
Convenience wrapper for addExtensionUpdate() when adding a new table (which is the most common usage of updaters in an extension)
$tableName | String Name of table to create |
$sqlPath | String Full path to the schema file |
Definition at line 178 of file DatabaseUpdater.php.
DatabaseUpdater::addExtensionUpdate | ( | Array $ | update | ) |
Add a new update coming from an extension.
This should be called by extensions while executing the LoadExtensionSchemaUpdates hook.
$update | Array: the update to run. Format is the following: first item is the callback function, it also can be a simple string with the name of a function in this class, following elements are parameters to the function. Note that callback functions will receive this object as first parameter. |
Definition at line 165 of file DatabaseUpdater.php.
DatabaseUpdater::addField | ( | $ | table, |
$ | field, | ||
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
Add a new field to an existing table.
$table | String Name of the table to modify |
$field | String Name of the new field |
$patch | String Path to the patch file |
$fullpath | Boolean Whether to treat $patch path as a relative or not |
Definition at line 447 of file DatabaseUpdater.php.
References applyPatch(), and output().
DatabaseUpdater::addIndex | ( | $ | table, |
$ | index, | ||
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
Add a new index to an existing table.
$table | String Name of the table to modify |
$index | String Name of the new index |
$patch | String Path to the patch file |
$fullpath | Boolean Whether to treat $patch path as a relative or not |
Definition at line 466 of file DatabaseUpdater.php.
References applyPatch(), and output().
Add a maintenance script to be run after the database updates are complete.
$class | string Name of a Maintenance subclass |
Definition at line 212 of file DatabaseUpdater.php.
DatabaseUpdater::addTable | ( | $ | name, |
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
Add a new table to the database.
$name | String Name of the new table |
$patch | String Path to the patch file |
$fullpath | Boolean Whether to treat $patch path as a relative or not |
Definition at line 430 of file DatabaseUpdater.php.
References applyPatch(), and output().
DatabaseUpdater::applyPatch | ( | $ | path, |
$ | isFullPath = false |
||
) | [protected] |
Applies a SQL patch.
$path | String Path to the patch file |
$isFullPath | Boolean Whether to treat $path as a relative or not |
Definition at line 416 of file DatabaseUpdater.php.
References $path.
Referenced by addField(), addIndex(), PostgresUpdater\addPgExtIndex(), addTable(), MysqlUpdater\checkBin(), PostgresUpdater\checkIpbAdress(), PostgresUpdater\checkIwlPrefix(), PostgresUpdater\checkPageDeletedTrigger(), PostgresUpdater\checkRcCurIdNullable(), PostgresUpdater\checkRevUserFkey(), PostgresUpdater\convertArchive2(), MysqlUpdater\doBacklinkingIndicesUpdate(), MysqlUpdater\doCategorylinksIndicesUpdate(), MysqlUpdater\doClFieldsUpdate(), MysqlUpdater\doFilearchiveIndicesUpdate(), MysqlUpdater\doFixAncientImagelinks(), OracleUpdater\doFKRenameDeferr(), OracleUpdater\doFunctions17(), MysqlUpdater\doIndexUpdate(), MysqlUpdater\doInterwikiUpdate(), MysqlUpdater\doLangLinksLengthUpdate(), MysqlUpdater\doMaybeProfilingMemoryUpdate(), OracleUpdater\doNamespaceDefaults(), MysqlUpdater\doPagelinksUpdate(), OracleUpdater\doPageRestrictionsPKUKFix(), OracleUpdater\doRebuildDuplicateFunction(), OracleUpdater\doRecentchangesFK2Cascade(), OracleUpdater\doRemoveNotNullEmptyDefaults(), OracleUpdater\doRemoveNotNullEmptyDefaults2(), MysqlUpdater\doRestrictionsUpdate(), OracleUpdater\doSchemaUpgrade17(), MysqlUpdater\doTemplatelinksUpdate(), MysqlUpdater\doUniquePlTlIl(), MysqlUpdater\doUpdateMimeMinorField(), doUpdateTranscacheField(), MysqlUpdater\doUserGroupsUpdate(), MysqlUpdater\doUserNewTalkTimestampNotNull(), MysqlUpdater\doUserUniqueUpdate(), MysqlUpdater\doWatchlistNull(), dropField(), dropIndex(), dropTable(), modifyField(), MysqlUpdater\renameEuWikiId(), SqliteUpdater\sqliteInitialIndexes(), SqliteUpdater\sqliteSetupSearchindex(), and PostgresUpdater\tsearchFixes().
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
Definition at line 346 of file DatabaseUpdater.php.
Referenced by insertUpdateRow(), and setAppliedUpdates().
DatabaseUpdater::checkStats | ( | ) | [protected] |
Check the site_stats table is not properly populated.
Definition at line 565 of file DatabaseUpdater.php.
References SiteStatsInit\doAllAndCommit(), and output().
Referenced by doUpdates().
DatabaseUpdater::doActiveUsersInit | ( | ) | [protected] |
Sets the number of active users in the site_stats table.
Definition at line 584 of file DatabaseUpdater.php.
References output().
DatabaseUpdater::doCollationUpdate | ( | ) | [protected] |
Update CategoryLinks collation.
Definition at line 648 of file DatabaseUpdater.php.
References $wgCategoryCollation, and output().
DatabaseUpdater::doLogSearchPopulation | ( | ) | [protected] |
Migrate log params to new table and index for searching.
Definition at line 618 of file DatabaseUpdater.php.
References output(), and updateRowExists().
DatabaseUpdater::doLogUsertextPopulation | ( | ) | [protected] |
Populates the log_user_text field in the logging table.
Definition at line 602 of file DatabaseUpdater.php.
References output(), and updateRowExists().
DatabaseUpdater::doMigrateUserOptions | ( | ) | [protected] |
Migrates user options from the user table blob to user_properties.
Definition at line 669 of file DatabaseUpdater.php.
References output().
DatabaseUpdater::doUpdates | ( | $ | what = array( 'core', 'extensions', 'purge', 'stats' ) | ) |
Do all the updates.
$what | Array: what updates to perform |
Reimplemented in OracleUpdater.
Definition at line 239 of file DatabaseUpdater.php.
References $wgLocalisationCacheConf, $wgVersion, checkStats(), getCoreUpdateList(), getExtensionUpdates(), getOldGlobalUpdates(), purgeCache(), rebuildLocalisationCache(), runUpdates(), and setAppliedUpdates().
DatabaseUpdater::doUpdateTranscacheField | ( | ) | [protected] |
Updates the timestamps in the transcache table.
Definition at line 634 of file DatabaseUpdater.php.
References applyPatch(), output(), and updateRowExists().
DatabaseUpdater::dropField | ( | $ | table, |
$ | field, | ||
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
Drop a field from an existing table.
$table | String Name of the table to modify |
$field | String Name of the old field |
$patch | String Path to the patch file |
$fullpath | Boolean Whether to treat $patch path as a relative or not |
Definition at line 484 of file DatabaseUpdater.php.
References applyPatch(), and output().
DatabaseUpdater::dropIndex | ( | $ | table, |
$ | index, | ||
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
Drop an index from an existing table.
$table | String: Name of the table to modify |
$index | String: Name of the old index |
$patch | String: Path to the patch file |
$fullpath | Boolean: Whether to treat $patch path as a relative or not |
Definition at line 502 of file DatabaseUpdater.php.
References applyPatch(), and output().
DatabaseUpdater::dropTable | ( | $ | table, |
$ | patch, | ||
$ | fullpath = false |
||
) | [protected] |
$table | string |
$patch | string |
$fullpath | bool |
Definition at line 517 of file DatabaseUpdater.php.
References applyPatch(), and output().
DatabaseUpdater::getCoreUpdateList | ( | ) | [abstract, protected] |
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)
Reimplemented in PostgresUpdater, OracleUpdater, Ibm_db2Updater, MysqlUpdater, and SqliteUpdater.
Referenced by doUpdates().
Get a database connection to run updates.
Definition at line 131 of file DatabaseUpdater.php.
DatabaseUpdater::getExtensionUpdates | ( | ) | [protected] |
Get the list of extension-defined updates.
Definition at line 221 of file DatabaseUpdater.php.
Referenced by doUpdates().
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.
Reimplemented in PostgresUpdater.
Definition at line 359 of file DatabaseUpdater.php.
References $updates, $wgSharedDB, and $wgSharedTables.
Referenced by doUpdates().
DatabaseUpdater::initOldGlobals | ( | ) | [private] |
Initialize all of the old globals.
One day this should all become something much nicer
Definition at line 76 of file DatabaseUpdater.php.
Referenced by __construct().
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!
$key | String Name of key to insert |
$val | String [optional] value to insert along with the key |
Definition at line 328 of file DatabaseUpdater.php.
References canUseNewUpdatelog().
Referenced by modifyField().
DatabaseUpdater::loadExtensions | ( | ) | [private] |
Loads LocalSettings.php, if needed, and initialises everything needed for LoadExtensionSchemaUpdates hook.
Definition at line 93 of file DatabaseUpdater.php.
References $wgAutoloadClasses, $wgHooks, and Installer\getExistingLocalSettings().
Referenced by __construct().
DatabaseUpdater::modifyField | ( | $ | table, |
$ | field, | ||
$ | patch, | ||
$ | fullpath = false |
||
) |
Modify an existing field.
$table | String: name of the table to which the field belongs |
$field | String: name of the field to modify |
$patch | String: path to the patch file |
$fullpath | Boolean: whether to treat $patch path as a relative or not |
Definition at line 535 of file DatabaseUpdater.php.
References applyPatch(), insertUpdateRow(), output(), and updateRowExists().
static DatabaseUpdater::newForDB | ( | &$ | db, |
$ | shared = false , |
||
$ | maintenance = null |
||
) | [static] |
MWException |
DatabaseBase | $db | |
bool | $shared | |
null | $maintenance |
Definition at line 116 of file DatabaseUpdater.php.
References $db, $maintenance, $shared, and Installer\getDBTypes().
Referenced by DatabaseInstaller\createExtensionTables(), DatabaseInstaller\doUpgrade(), and DatabaseSqliteTest\prepareDB().
DatabaseUpdater::output | ( | $ | str | ) |
Output some text.
If we're running from web, escape the text first.
$str | String: Text to output |
Definition at line 140 of file DatabaseUpdater.php.
References $wgCommandLineMode, and echo.
Referenced by addField(), addIndex(), PostgresUpdater\addPgExtIndex(), PostgresUpdater\addPgField(), PostgresUpdater\addPgIndex(), PostgresUpdater\addSequence(), addTable(), PostgresUpdater\changeField(), PostgresUpdater\changeFkeyDeferrable(), PostgresUpdater\changeNullableField(), MysqlUpdater\checkBin(), PostgresUpdater\checkIpbAdress(), PostgresUpdater\checkIwlPrefix(), PostgresUpdater\checkOiDeleted(), PostgresUpdater\checkOiNameConstraint(), PostgresUpdater\checkPageDeletedTrigger(), PostgresUpdater\checkPagelinkUniqueIndex(), PostgresUpdater\checkRcCurIdNullable(), PostgresUpdater\checkRevUserFkey(), checkStats(), PostgresUpdater\convertArchive2(), doActiveUsersInit(), MysqlUpdater\doBacklinkingIndicesUpdate(), MysqlUpdater\doCategorylinksIndicesUpdate(), MysqlUpdater\doCategoryPopulation(), MysqlUpdater\doClFieldsUpdate(), doCollationUpdate(), MysqlUpdater\doFilearchiveIndicesUpdate(), MysqlUpdater\doFixAncientImagelinks(), OracleUpdater\doFKRenameDeferr(), OracleUpdater\doFunctions17(), MysqlUpdater\doIndexUpdate(), OracleUpdater\doInsertPage0(), MysqlUpdater\doInterwikiUpdate(), MysqlUpdater\doLangLinksLengthUpdate(), doLogSearchPopulation(), doLogUsertextPopulation(), MysqlUpdater\doMaybeProfilingMemoryUpdate(), doMigrateUserOptions(), OracleUpdater\doNamespaceDefaults(), MysqlUpdater\doNamespaceSize(), MysqlUpdater\doPagelinksUpdate(), MysqlUpdater\doPageRandomUpdate(), OracleUpdater\doPageRestrictionsPKUKFix(), MysqlUpdater\doPopulateParentId(), OracleUpdater\doRebuildDuplicateFunction(), OracleUpdater\doRecentchangesFK2Cascade(), OracleUpdater\doRemoveNotNullEmptyDefaults(), OracleUpdater\doRemoveNotNullEmptyDefaults2(), MysqlUpdater\doRestrictionsUpdate(), MysqlUpdater\doSchemaRestructuring(), OracleUpdater\doSchemaUpgrade17(), MysqlUpdater\doTemplatelinksUpdate(), MysqlUpdater\doUniquePlTlIl(), MysqlUpdater\doUpdateMimeMinorField(), doUpdateTranscacheField(), MysqlUpdater\doUserGroupsUpdate(), MysqlUpdater\doUserNewTalkTimestampNotNull(), MysqlUpdater\doUserUniqueUpdate(), MysqlUpdater\doWatchlistNull(), MysqlUpdater\doWatchlistUpdate(), dropField(), dropIndex(), dropTable(), MysqlUpdater\indexHasField(), modifyField(), OracleUpdater\purgeCache(), purgeCache(), rebuildLocalisationCache(), MysqlUpdater\renameEuWikiId(), PostgresUpdater\renameSequence(), PostgresUpdater\renameTable(), SqliteUpdater\sqliteInitialIndexes(), SqliteUpdater\sqliteSetupSearchindex(), and PostgresUpdater\tsearchFixes().
DatabaseUpdater::purgeCache | ( | ) | [protected] |
Purge the objectcache table.
Reimplemented in OracleUpdater.
Definition at line 554 of file DatabaseUpdater.php.
References output().
Referenced by doUpdates().
DatabaseUpdater::rebuildLocalisationCache | ( | ) | [protected] |
Rebuilds the localisation cache.
Definition at line 678 of file DatabaseUpdater.php.
References output().
Referenced by doUpdates().
DatabaseUpdater::runUpdates | ( | array $ | updates, |
$ | passSelf | ||
) | [private] |
Helper function for doUpdates()
$updates | Array of updates to run |
$passSelf | Boolean: whether to pass this object we calling external functions |
Definition at line 273 of file DatabaseUpdater.php.
Referenced by doUpdates().
DatabaseUpdater::setAppliedUpdates | ( | $ | version, |
$ | updates = array() |
||
) | [protected] |
$version | |
$updates | array |
Definition at line 291 of file DatabaseUpdater.php.
References $updates, and canUseNewUpdatelog().
Referenced by doUpdates().
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!
$key | String Name of the key to check for |
Definition at line 311 of file DatabaseUpdater.php.
Referenced by MysqlUpdater\doCategoryPopulation(), MysqlUpdater\doClFieldsUpdate(), doLogSearchPopulation(), doLogUsertextPopulation(), MysqlUpdater\doPopulateParentId(), MysqlUpdater\doUpdateMimeMinorField(), doUpdateTranscacheField(), modifyField(), SqliteUpdater\sqliteInitialIndexes(), and SqliteUpdater\sqliteSetupSearchindex().
DatabaseUpdater::$db [protected] |
Reimplemented in OracleUpdater, and PostgresUpdater.
Definition at line 38 of file DatabaseUpdater.php.
Referenced by __construct(), and newForDB().
DatabaseUpdater::$extensionUpdates = array() [protected] |
Definition at line 31 of file DatabaseUpdater.php.
DatabaseUpdater::$postDatabaseUpdateMaintenance [protected] |
array( 'DeleteDefaultMessages', 'PopulateRevisionLength', 'PopulateRevisionSha1', 'PopulateImageSha1', 'FixExtLinksProtocolRelative', )
Definition at line 42 of file DatabaseUpdater.php.
DatabaseUpdater::$shared = false [protected] |
Definition at line 40 of file DatabaseUpdater.php.
Referenced by __construct(), and newForDB().
DatabaseUpdater::$updates = array() [protected] |
Definition at line 25 of file DatabaseUpdater.php.
Referenced by PostgresUpdater\getOldGlobalUpdates(), getOldGlobalUpdates(), and setAppliedUpdates().