Extension:UserMerge/UserMergeAccountFields

From MediaWiki.org
Jump to: navigation, search
UserMergeAccountFields
Available from version ??? (Gerrit change 145146)
define database fields to be automatically updated from the old user ID / username to the new one
Define function:
public static function onUserMergeAccountFields( &$updateFields ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"UserMergeAccountFields": "MyExtensionHooks::onUserMergeAccountFields"
	}
}

For MediaWiki ≤1.25:

$wgHooks['UserMergeAccountFields'][] = 'MyExtensionHooks::onUserMergeAccountFields';
Called from: File(s): UserMerge extension

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UserMergeAccountFields extensions.

Details[edit]

  • &$updateFields: an array containing a list of field configurations. Each configuration is in the form array( $tableName, $idField, $textField, 'batchKey' => $batchKey, 'options' => $options, 'db' => $db ). Everything except $tableName and $idField is optional.
    • $tableName: name of the table containing the field(s) to update
    • $idField: field containing the user ID
    • $textField: field containing the username
    • $batchKey: primary key of the table. If present, update will be done in batches.
    • $options: options array for Database::update(). Typically used to ignore duplicate keys.
    • $db: DB connection to use

If the update operation is too complex to be handled this way, MergeAccountFromToExtension:UserMerge/MergeAccountFromTo can be used instead.