Manual:Hooks/APIQueryRevisionsTokens

Category:MediaWiki hooks#APIQueryRevisionsTokens Category:Hooks added in MediaWiki 1.13.0#APIQueryRevisionsTokens Category:MediaWiki deprecated or obsolete features#APIQueryRevisionsTokens Category:Hooks removed in MediaWiki 1.36.0#APIQueryRevisionsTokens Category:Hooks deprecated in MediaWiki 1.24.0#APIQueryRevisionsTokens
APIQueryRevisionsTokens
Available from version 1.13.0
Removed in version 1.36.0 (Gerrit change 625758)Category:Removed hooks#APIQueryRevisionsTokens
Use this hook to add custom tokens to prop=revisions.
Define function:
public static function onAPIQueryRevisionsTokens( &$tokenFunctions ) { ... }
Attach hook: In extension.json:
{
	"Hooks": {
		"APIQueryRevisionsTokens": "MediaWiki\\Extension\\MyExtension\\Hooks::onAPIQueryRevisionsTokens"
	}
}
Called from: File(s): api/ApiQueryRevisions.phpCategory:MediaWiki hooks included in ApiQueryRevisions.php#APIQueryRevisionsTokens
Interface: APIQueryRevisionsTokensHook.php

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

Details

  • $tokenFunctions: array(action => callback)

Notes

Every token has an action, which will be used in the rvtoken parameter and in the output (actiontoken="..."), and a callback function which should return the token, or false if the user isn't allowed to obtain it.

The prototype of the callback function is func($pageid, $title, $rev) where $pageid is the page ID of the page associated to the revision the token is requested for, $title the associated Title object and $rev the associated Revision object.

In the hook, just add your callback to the $tokenFunctions array and return true (returning false makes no sense)

Category:Hooks added in MediaWiki 1.13.0 Category:Hooks deprecated in MediaWiki 1.24.0 Category:Hooks removed in MediaWiki 1.36.0 Category:MediaWiki deprecated or obsolete features Category:MediaWiki hooks Category:MediaWiki hooks included in ApiQueryRevisions.php Category:Removed hooks