Template:NNikkhoui (WMF)/sandbox/Template:MediaWikiHook

From Bonkipedia


Template documentation

Copy and paste template

MyHook
<translate> Available from <tvar name=1><translate> version <tvar </tvar></translate>

<translate> Define function:</translate>
public static function onMyHook( $x, $y ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"MyHook": "MyExtensionHooks::onMyHook"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate>
<translate> Interface:</translate> MyHookHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:MyHook extensions</tvar>.</translate>

{{MediaWikiHook
|name = MyHook
|version =
|gerrit =
|removed =
|summary =
|args = $x, $y
|source =
|sourcefunction =
|sourceclass =
|newvarname =
|newvarlink =
}}

Usage notes

A card which describes the information of a MediaWiki-registered hook.

Template parameters

This template prefers block formatting of parameters.

ParameterDescriptionTypeStatus
Template modetemplatemode

Set to nocats if hook documentation should not appear in standard MediaWiki Categories. By default, using this template places the documentation page into categories: MediaWiki hooks Hooks added in MediaWiki... There are times when it is undesirable to automatically categorize the hook documentation. Examples would include when documenting a hook in an extension, or when documenting the template itself.

Unknownoptional
Namename

The name of the hook. This is usually the same name as the sub-page.

Unknownoptional
Versionversion

The version of MediaWiki this hook was first introduced in.

Unknownsuggested
Version removedremoved

If the hook has been removed, the version of MediaWiki that it was removed in.

Stringoptional
New variable namenewvarname

no description

Unknownoptional
New variable linknewvarlink

no description

Unknownoptional
Version deprecateddeprecated

If the hook has been deprecated (but not removed), the version of MediaWiki that it was deprecated in.

Unknownoptional
SVN revision introducedrev

SVN revision in which this hook was first introduced. If this parameter is given, it'll link to the appropriate CodeReview page (e.g. [[phabricator:rSVN1]]).

Unknownoptional
Gerrit changesetgerrit

Gerrit change number in which this hook was first introduced. If this parameter is given, it'll link to the appropriate Gerrit changeset page (e.g. Gerrit change 1)

Unknownsuggested
Summarysummary

A short description of the hook's purpose. More detailed descriptions are desirable, and should be added to the main page content.

Unknownrequired
Argumentsargs

The arguments, as used at the top of the function.

Unknownrequired
Extensionextension

no description

Unknownoptional
File sourcesource

Location (file name/path not including <code>includes/</code>) which calls this hook in the code. Further locations can be added via source2...source10.

Unknownsuggested
File source 2source2

no description

Unknownoptional
File source 3source3

no description

Unknownoptional
File source 4source4

no description

Unknownoptional
File source 5source5

no description

Unknownoptional
File source 6source6

no description

Unknownoptional
File source 7source7

no description

Unknownoptional
File source 8source8

no description

Unknownoptional
File source 9source9

no description

Unknownoptional
File source 10source10

no description

Unknownoptional
Function sourcesourcefunction

Name of the function which calls this hook. Another can be added via sourcefunction2.

Unknownsuggested
Function source 2sourcefunction2

no description

Unknownoptional
Class sourcesourceclass

Name of the class which calls this hook.

Unknownsuggested
name
The name of the hook. This is usually the same name as the sub-page.
version
The version of MediaWiki this hook was first introduced in.
rev
SVN revision in which this hook was first introduced. If this parameter is given, it'll link to the appropriate CodeReview page (e.g. phabricator:rSVN1).
gerrit
Gerrit change number in which this hook was first introduced. If this parameter is given, it'll link to the appropriate Gerrit changeset page (e.g. Gerrit change 1)
removed
If the hook has been removed, the version of MediaWiki that it was removed in.
deprecated
If the hook has been deprecated (but not removed), the version of MediaWiki that it was deprecated in.
summary
A short description of the hook's purpose.
More detailed descriptions are desirable, and should be added to the main page content.
If you update the short description, please also update the two tables on Manual:Hooks .
args
The arguments, as used at the top of the function.
source
Location (file name) which calls this hook in the code. Further locations can be added via source2...source10.
sourcefunction
Name of the function which calls this hook. Another can be added via sourcefunction.
sourceclass
Name of the class which calls this hook.
templatemode
Set to nocats if hook documentation should not appear in standard MediaWiki Categories.
By default, using this template places the documentation page into categories:
  • MediaWiki hooks
  • Hooks added in MediaWiki...
There are times when it is undesirable to automatically categorize the hook documentation. Examples would include when documenting a hook in an extension, or when documenting the template itself.

Finding a hook's version and Gerrit ID

To populate the version and gerrit attributes of this template, you may need to search the history of the docs/hooks.txt file.

  1. (From the top-level of a Git clone of MediaWiki source code)
  2. Find the oldest commit to hooks.txt that mentions the hook:
    • git grep <hook-name-here> $(git rev-list --all -- docs/hooks.txt) -- docs/hooks.txt | tail -n 1
  3. Find its Gerrit ID:
    • git log <commit-from-above>
    1. Copy the change-id from the log entry into the Gerrit search box
    2. Select the relevant change, and get its ID
  4. Find out what release the hook was first included in:
    • git tag --contains <commit-from-above>