Manual:Hooks/LinksUpdateAfterInsert

From MediaWiki.org
Jump to navigation Jump to search
LinksUpdateAfterInsert
Available from version 1.21.0 (Gerrit change 41810)
Occurs right after new links have been inserted into the links table
Define function:
public static function onLinksUpdateAfterInsert( $linksUpdate, $table, $insertions ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"LinksUpdateAfterInsert": "MyExtensionHooks::onLinksUpdateAfterInsert"
	}
}

For MediaWiki ≤1.25:

$wgHooks['LinksUpdateAfterInsert'][] = 'MyExtensionHooks::onLinksUpdateAfterInsert';
Called from:File(s): LinksUpdate.php
Function(s): LinksUpdate::incrTableUpdate()

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

Details[edit]

  • $linksUpdate: the LinksUpdate object calling the hook
  • $table: the name of the table that was just inserted into
  • $insertions: an array of the links that were inserted

The function should return true to continue hook processing or false to abort.

Notes[edit]

It runs if $wgUseDumbLinkUpdate is false (meaning incremental updates were done), and at least one link is inserted. It is called for all types of links, from LinksUpdate->incrTableUpdate, after both deletion then insertion are done.

Example handler[edit]

/**
 * Handler for LinksUpdateAfterInsert hook.
 * @see http://www.mediawiki.org/wiki/Manual:Hooks/LinksUpdateAfterInsert
 * @param $linksUpdate LinksUpdate
 * @param $table string
 * @param $insertions array
 * @return bool
 */
public static function onLinksUpdateAfterInsert( $linksUpdate, $table, $insertions ) {

See also[edit]