Movatterモバイル変換


[0]ホーム

URL:


Jump to content
MediaWiki
Search

Manual:Hooks

From mediawiki.org
(Redirected fromManual:PHP hooks)
Translate this page
Languages:
See also:Manual:JavaScript hooks
MediaWiki extensions

PHP hooks allow custom code to be executed when some defined action (such as saving a page or a user logging in) is performed.For example, the following code snippet will trigger a call to the functionMyExtensionHooks::onEditFilter whenever theEditFilter hook runs, passing it function arguments specific toEditFilter.In this way, the EditFilter hook allows extensions to examine edits and prevent them when appropriate.

Hooks are also sometimes used to inform extensions about thecompletion of actions, e.g. thePageSaveComplete hook is triggered after pages were changed.Starting withMW 1.44, the preferred mechanism for extensions to be notified aboutcompleted changes is thedomain events system.However, domain events have not yet been defined for all relevant changes, they will become available gradually with future releases of MediaWiki.For instance, starting withMW 1.45, thePageLatestRevisionChanged event should be used instead of thePageSaveComplete hook.Existing events can be found on theevent hierarchy page.

Hooks can be registered by mapping the name of the hook to the callback in the extension'sextension.json file:

"Hooks":{"EditFilter":"MyExtensionHooks::onEditFilter","MyCustomHook":"MyExtensionHooks::myCustomHook"}

MediaWiki provides manyhooks like this toextend the functionality of the MediaWiki software.Assigning a function (known as ahook handler) to a hook will cause that function to be called at the appropriate point in the main MediaWiki code, to perform whatever additional task(s) the developer thinks would be useful at that point.Each hook can have multiple handlers assigned to it, in which case it will call the functions in the order that they are assigned, with any modifications made by one function passed on to subsequent functions in the chain.

Assign functions to hooks at theend ofLocalSettings.php or in your own extension file at the file scope (not in a$wgExtensionFunctions function or theParserFirstCallInit hook).For extensions, if the hook function's behaviour is conditioned on a setting in LocalSettings.php, the hook should be assigned and the function should terminate early if the condition was not met.

Background

A hook is triggered by a call toHookContainer::run, usually via a method in HookRunner.HookContainer will find the hook handlers to run and call them with the parameters given toHookContainer::run.Hook handlers are registered viaextension.json.

See alsoHooks.md.

In this example from thedoPurge function inWikiPage.php, doPurge callsHookRunner::onArticlePurge to run theArticlePurge hook, passing$this as argument:

$this->getHookRunner()->onArticlePurge($this)

TheCore calls many hooks, butExtensions can also call hooks.

Writing a hook

In addition to calling hooks, you can also create new hooks in your own extension.

Set up a HookRunner

Although not all extensions choose to do so, it is recommended that you create an implementation of theHookRunner class:

  • Register your new hook in extension.json the same way as if you were registering a built-in MediaWiki hook to use in your extension.
  • Create a hook interface, typically in a subnamespace calledHook relative to the caller namespace. For example, if the caller is in a namespace calledMyExtension\Foo, the hook interface might be placed inMyExtension\Foo\Hook. The hook interface can register multiple hooks.
  • Add an implementation to the relevantHookRunner class, typically in the same subnamespace.

Run your hook with HookContainer

You can run your hook within your extension by callingHookContainer::run( 'HookName', [ $param1, $param2 ] );.

First, create a HookContainer.

$hookContainer=MediaWikiServices::getInstance()->getHookContainer();

If you set up a HookRunner as recommended above, you can run your hook (hereonGetFooBar) as in this example:

$myHookRunner=newMyExtension\Foo\Hook\myHookRunner($hookContainer);// The hook you registered in MyExtension\Foo\Hook$myHookRunner->onGetFooBar($out,$attributes);

If you did not set up a HookRunner, you can still call the HookContainer with a unique name that represents your hook.To guarantee it's unique, it may be helpful to prefix it with the name of your extension :

$hookContainer->run("MyExtensionName::GetFooBar",[$out,&$attributes]);

Other

Lastly, don't forget to add your hooks to the extension's page (seeTemplate:Extension) so that they will appear inCategory:Extension hooks.

Writing a hook handler

In order to make use of a hook, you need a hook handler.A hook handler is a function that you register and that will be called whenever the hook in question is run.

For extensions, register your hook handlers inextension.json:

{"Hooks":{"EventName":["MyExtensionHooks::onEventName","someFunction"]}}

Hook handlers can also be registered via the global$wgHooks array.This is most commonly used for site-specific customisations inLocalSettings.php, or in legacy extensions that predateextension.json.All the following are valid ways to define a hook handler for theEventName hook, with two parameters passed:

FormatSyntaxResulting function call.
Static function$wgHooks['EventName'][]='MyExtensionHooks::onEventName';MyExtensionHooks::onEventName($param1,$param2);
Function, no data$wgHooks['EventName'][]='efSomeFunction';efSomeFunction($param1,$param2);
Function with data$wgHooks['EventName'][]=['efSomeFunction',$someData];efSomeFunction($someData,$param1,$param2);
Inline anonymous function
$wgHooks['EventName'][]=function($param1,$param2){// ...function body};
Object only$wgHooks['EventName'][]=$object;$object->onEventName($param1,$param2);
Object with method$wgHooks['EventName'][]=[$object,'someMethod'];$object->someMethod($param1,$param2);
Object with method and data$wgHooks['EventName'][]=[$object,'someMethod',$someData];$object->someMethod($someData,$param1,$param2);

Note that when an object is assigned, and you don't specify a method, the method called is "onEventName".For example "onArticleSave", "onUserLogin", etc.

The optional data is useful if you want to use the same function or object for different purposes. For example:

$wgHooks['EditFilter'][]=['efIrcNotify','TimStarling'];$wgHooks['EditFilter'][]=['efIrcNotify','brooke'];

This code would result inefIrcNotify() being run twice when a page is saved: once for 'TimStarling', and once for 'brooke'.

Hook handler return values

Hooks fall into one of two categories, distinguished by the supported return values:

MediaWiki version:
1.23

Void hooks

A void hook does not return anything. Void hook should be the most common kind in new code (T245364).

  • Documentation:@return void
  • Usage:$hookRunner->onExample();

The interface for void hooks must include a native return type hint like: void, so that extensions that choose to implement the interface (as opposed to handling it without interface validation), benefit from static analysis and thus avoid accidentally returning something.This prevents severe bugs that are hard to catch otherwise (T173615). These hooks ignore the return value and so in isolation, a return value is simply unused, harmless, with no visible effect.In production, it would cancel listeners from other extensions for the same hook.Effectively undeploying only part of an extension this way can have major consequences.

Abortable hooks

Abortable hooks may return boolean false.When a non-void return value is given to an abortable hook, it skips any and all other listeners for the same hook (i.e. in other extensions), and returns false to the hook caller.This is similar toEvent.stopImmediatePropagation() andEvent.preventDefault() in JavaScript.

If as the author of a feature, you want to allow an extension to disallow or cancel the user action, you can provide an abortable hook for this.

  • Documentation:@return bool|void
  • Usage:if ( $hookRunner->onExample() ) { … }

It is important that abortable hooks allow a void return. The majority of hook consumers do not make use of the abortable feature, and thus should be able to type their implementation to@return void and safely avoid the need to return something, and with it benefit from having no room for mistakingly returning false.

Return values:

  • void (no return value, ornull) - the hook handler finished successfully. (Before MediaWiki 1.23, returningtrue was required.)
  • false - the hook handler has done all the work necessary, or replaced normal handling. This will prevent further handlers from being run, and in some cases tells the calling function to skip normal processing.
Usually when extensions allow you to cancel an action, the hook also provides a Status object where a localised error can be set.
MediaWiki version:
1.40

Prior to MediaWiki 1.41, abortable hooks could return an error message as string. This was a shortcut for producing an Internal Server Error (HTTP 500) response with the returned string displayed as the fatal error. This was deprecated in MW 1.35 (Gerrit change 571297), and removed in MW 1.41 (Gerrit change 571297).

Handling hooks in MediaWiki 1.35 and later

MediaWiki version:
1.35

MediaWiki 1.35 introduces the HookHandlers extension attribute.This includes per-hook interfaces for improved static validation and discovery of parameter documentation.It also enables dependency injection by introducing an intermediary class instance that accepts a number of specified services (instead of static callbacks that explicitly access services from global state).

The approach from MediaWiki 1.34 and earlier, of registering hook handlers directly as static methods, remains supported and is not deprecated.Extension authors may opt-in to the new system are welcome to do so.To learn more, see theMediaWiki core: Hook specification and theannouncement on wikitech-l.

Changes to hook names

Prior to MediaWiki 1.35, hooks sometimes included characters that could not be used in a class or method name, such as colons and dashes.With the introduction of per-hook interfaces, the canonical names of these hooks have been changed to use underscores instead.For example, the interface forApiFeedContributions::feedItem isApiFeedContributions__feedItemHook.Hook handlers that are registered with the old names remain supported.

Registering hooks using HookHandlers

To adopt the new system, change your Hooks class to have regular methods instead of static methods and to be constructible.This class is then registered once, via theHookHandlers attribute inextension.json, using theclass option as part of anObjectFactory description where you can use theservices option.

For example, to register theBeforePageDisplay hook:

{"HookHandlers":{"main":{"class":"MediaWiki\\Extension\\Example\\Hooks","services":["UserNameUtils"]}},"Hooks":{"BeforePageDisplay":"main"}}

Handling hooks using interfaces

To use hook interfaces, extensions should define a Hooks class in their namespace and implement one or more hook interfaces.Hook interfaces are named with the hook name followed by the word "Hook".

<?phpnamespaceMediaWiki\Extension\Example;useMediaWiki\Output\Hook\BeforePageDisplayHook;useMediaWiki\Output\OutputPage;useMediaWiki\Skin\Skin;useMediaWiki\User\UserNameUtils;classHooksimplementsBeforePageDisplayHook{privateUserNameUtils$userNameUtils;publicfunction__construct(UserNameUtils$userNameUtils){$this->userNameUtils=$userNameUtils;}publicfunctiononBeforePageDisplay($out,$skin):void{...}}

Convert an extension to the new hook system

Follow these steps for each hook handling method:

  • identify the hook handler interface, and make the Hooks class implement this interface.
  • update the method name and signature to be exactly the same as in the interface.
  • change the Hooks section ofextension.json to refer to the handler you specified in the HookHandlers section.

The process was demonstrated at theWikimedia Hackathon 2021:

Documentation

Currently, hooks in MediaWiki core have to be documented both inhook interface (in the source code repository) andCategory:MediaWiki hooks here on MediaWiki.org.In some cases, one of these steps may not yet have been completed, so if a hook appears undocumented, check both.

Each hook provided by MediaWiki Core is defined in a hook interface.Typically, hook interfaces are located in a "Hook" sub-namespace inside the caller namespace.For example,Storage/Hook/PageContentSaveHook.php.You can find a list of hook interfaces in thegenerated MediaWiki PHP documentation.

To document a hook on-wiki, use {{MediaWikiHook}}.

As of June 2020,docs/hooks.txt is deprecated as a source of documentation for individual hooks. For more information about the introduction of hooks based on HookContainer, see thehook specification in MediaWiki Core.

Hook interface doc template

In hook interfaces, doc comments specify the status, purpose, parameters, and behaviour of the hook.

<?phpnamespaceMediaWiki\Extension\Example;/** * @stable for implementation * @ingroup Hooks */interfaceMyExampleHook{/** * This hook is called after/when... * Use this hook to... * * @since x.xx * @param string $name Description * @return void This hook must not abort, it must return no value */publicfunctiononMyExample($name):void;}
<?phpnamespaceMediaWiki\Extension\Example;/** * @stable for implementation * @ingroup Hooks */interfaceAbortableExampleHook{/** * This hook is called before... * Use this hook to... * * @since x.xx * @param string $name Description * @return bool|void True or no return value to continue or false to abort */publicfunctiononAbortableExample($name);}

Available hooks

Hooks grouped by function

Some of these hooks can be grouped into multiple functions.

Sections:Article Management -Edit Page -Page Rendering -User Interface -File Management -Special Pages -User Management -Logging -Skinning Templates -API -Import/Export -Diffs -Miscellaneous
WarningWarning:New hooks are added to MediaWiki fairly frequently, so this list is not always completely up to date. As with most documentation on this site, if you need complete up-to-the-minute information you are advised to consult the generatedlist of hook interfaces. As ever, you are encouraged to update this list to correct any errors or omissions.
FunctionVersionHookDescription
Article Management1.23.0Article::MissingArticleConditionsCalled when showing a page.
1.21ArticleAfterFetchContentObject(deprecated in 1.32) After fetching content of an article from the database.
1.16ArticleConfirmDeleteOccurs before writing the confirmation form for article deletion.
1.21ArticleContentViewCustom(removed in 1.35) Allows to output the text of the article in a different format than wikitext
1.25ArticleDeleteAfterSuccessOutput after an article has been deleted
1.4.0ArticleDeleteComplete(deprecated in 1.37) Occurs after the delete article request has been processed
1.4.0ArticleDelete(deprecated in 1.37) Occurs whenever the software receives a request to delete an article
1.5.7ArticleEditUpdateNewTalkAllows an extension to prevent user notification when a new message is added to their talk page.
1.6.0ArticleEditUpdatesDeleteFromRecentchangesOccurs before saving to the database. If returningfalse old entries are not deleted from the recentchangeslist.
1.14.0ArticleEditUpdates(deprecated in 1.35) Called when edit updates (mainly link tracking) are made when an article has been changed.
1.8.0ArticleFromTitleCalled to determine the class to handle the article rendering, based on title
1.12.0ArticleMergeCompleteAfter merging to article usingSpecial:Mergehistory
1.36ArticleParserOptionsThis hook is called before parsing wikitext for an article,
1.18ArticlePrepareTextForEditCalled when preparing text to be saved.
1.4.0ArticleProtectCompleteOccurs after the protect article request has been processed. Starting with MW 1.45, it is preferred to use thePageProtectionChanged event.
1.4.0ArticleProtectOccurs whenever the software receives a request to protect an article
1.6.0ArticlePurgeAllows an extension to cancel a purge.
1.12.0ArticleRevisionUndeleted(deprecated in 1.35) Occurs after an article revision is restored
1.32ArticleRevisionViewCustomAllows to output the text of an article revision in a different format than wikitext
1.13.0ArticleRevisionVisibilitySetCalled when changing visibility of one or more revisions of an article
1.12.0ArticleRollbackComplete(deprecated in 1.35) Occurs after an article rollback is completed. Starting with MW 1.45, it is preferred to use thePageLatestRevisionChanged event.
1.21ArticleUndeleteLogEntryOccurs when a log entry is generated but not yet saved
1.9.1ArticleUndeleteWhen one or more revisions of an article are restored
1.11.0ArticleUpdateBeforeRedirectOccurs after a page is updated (usually on save), before the user is redirected back to the page
1.18ArticleViewFooterAfter showing the footer section of an ordinary page view.
1.17CanonicalNamespacesFor extensions adding their own namespaces or altering the defaults.
1.25ChangeTagAfterDeleteCalled after a change tag has been deleted (that is, removed from all revisions and log entries to which it was applied).
1.25ChangeTagCanCreateTell whether a change tag should be able to be created by users.
1.25ChangeTagCanDeleteTell whether a change tag should be able to be deleted by users.
1.28ChangeTagsAfterUpdateTagsCan be used by extensions to take actions after change tags have been added or updated.
1.30ChangeTagsAllowedAddCalled when checking if a user can addtags to a change.
1.25ChangeTagsListActiveCan be used by extensions to register activechange tags.
1.21.0ContentHandlerDefaultModelForCalled when deciding the default content model for a given title.
1.21.0ContentHandlerForModelIDCalled when a ContentHandler is requested for a given content model name, but no entry for that model exists in$wgContentHandlers.
1.23ContentModelCanBeUsedOnargs = $modelId, Title $title, &$ok
1.21.0ConvertContentCalled when a conversion to another content model is requested.
1.29GetContentModelsAllows to add custom content handlers to the list of content models registered with the system.
1.39JsonValidateSaveUse this hook to add additional validations for JSON content pages.
1.19LanguageGetNamespacesProvide custom ordering for namespaces or remove namespaces.
1.25.0MovePageIsValidMoveSpecify whether a page can be moved for technical reasons.
1.35.0MultiContentSaveOccurs whenever the software receives a request to save an article
1.25MovePageCheckPermissionsSpecify whether the user is allowed to move the page.
1.20NamespaceIsMovableCalled when determining if it is possible to move pages, for a particular namespace. This controls moves both to and from the given namespace.
1.13NewRevisionFromEditComplete(deprecated in 1.35) Called when a revision was inserted due to an edit.
1.21PageContentInsertComplete(deprecated in 1.35) Occurs after a new article is created
1.18PageContentLanguageAllows changing thepage content language and consequently all features depending on that (writing direction, LanguageConverter, ...).
1.21.0PageContentSaveComplete(deprecated in 1.35) Occurs after the save article request has been processed
1.21.0PageContentSave(deprecated in 1.35)(use MultiContentSave) Occurs whenever the software receives a request to save an article
1.37.0PageDeleteOccurs whenever the software receives a request to delete a page.
1.37.0PageDeleteCompleteOccurs after the delete page request has been processed. Starting with MW 1.45, it is preferred to use thePageDeleted event.
1.32PageDeletionDataUpdatesCalled when constructing a list ofDeferrableUpdate to be executed when a page is deleted.
1.35PageMoveCompleteAfter an article has been moved, post commit. Starting with MW 1.45, it is preferred to use thePageMoved event.
1.35PageMoveCompletingAfter an article has been moved, pre commit
1.35PageSaveCompleteAfter an article has been updated. Starting with MW 1.45, it is preferred to use thePageLatestRevisionChangedChanged event.
1.37PageUndeleteRun before page undeletion.
1.40PageUndeleteCompleteRuns after a page undeletion. Starting with MW 1.45, it is preferred to use thePageCreated event for most use cases.
1.25PageViewUpdatesCalled after a page view is seen by MediaWiki. Note this does not capture views made via external caches such asSquid.
1.16ProtectionForm::buildForm(deprecated in 1.36) Called after all protection type fieldsets are made in the form.
1.16ProtectionForm::saveCalled when a protection form is submitted.
1.16ProtectionForm::showLogExtractCalled after the protection log extract is shown.
1.36ProtectionFormAddFormFieldsThis hook is called after all protection type form fields are added.
1.8.0RecentChange_saveCalled after a "Recent Change" is committed to the DB.
1.32RevisionDataUpdatesCalled when constructing a list ofDeferrableUpdate to be executed to record secondary data about a revision.
1.35RevisionFromEditCompleteCalled when a revision was inserted due to an edit, file upload, import or page move. Starting with MW 1.45, it is preferred to use thePageLatestRevisionChangedChanged event.
1.11.0RevisionInsertComplete(deprecated in 1.31)(use RevisionRecordInserted) Called after a revision is inserted into the DB
1.31RevisionRecordInsertedCalled after a revision is inserted into the database.
1.35RevisionUndeletedCalled after an article revision is restored
1.6.0SpecialMovepageAfterMoveCalled after a page is moved.
1.35RollbackComplete(deprecated in 1.36) Occurs after an article rollback is completed
1.15ListDefinedTagsCan be used by extensions to registerchange tags.
1.14TitleArrayFromResultCalled when creating aTitleArray object from a database result.
1.24TitleExistsCalled when determining whether a page exists at a given title.
1.22TitleGetEditNoticesCalled when theedit notices for a page are being retrieved.
1.16TitleGetRestrictionTypesAllows to modify the types of protection that can be applied.
1.20.0TitleIsAlwaysKnownAllows overriding default behaviour for determining if a page exists.
1.19TitleIsMovableCalled when determining if it is possible to move a page.
1.4.0TitleMoveComplete(deprecated in 1.35) Occurs whenever a request to move an article is completed
1.27TitleMoveCompleting(deprecated in 1.35) Occurs whenever a request to move an article is completed, before the database transaction commits.
1.27TitleMoveStartingBefore moving an article (title), but just after theatomic DB section starts.
1.22.0TitleMoveOccurs before a requested pagemove is performed
1.22TitleQuickPermissionsCalled fromTitle::checkQuickPermissions to allow skipping checking quick Title permissions (e.g., the 'delete' permission).
1.19TitleReadWhitelistCalled at the end of read permissions checks, just before adding the default error message if nothing allows the user to read the page.
1.18UndeleteForm::undelete(removed in 1.38) Called inUndeleteForm::undelete, after checking that the site is not in read-only mode, that theTitle object is notnull and after aPageArchive object has been constructed but before performing any further processing.
1.21WikiPageDeletionUpdates(removed in 1.36) Manipulate the list ofDeferrableUpdates to be applied when a page is deleted. Called inWikiPage::getDeletionUpdates(). Note that updates specific to a content model should be provided by the respective Content'sgetDeletionUpdates() method.
1.28WikiPageFactoryOverrideWikiPage class used for a title
Edit Page1.21.0AlternateEditPreviewAllows replacement of the edit preview
1.6.0AlternateEditUsed to replace the entire edit page, altogether.
1.9.1CustomEditorWhen invoking the page editor. Returntrue to allow the normal editor to be used, orfalse if implementing a custom editor, e.g. for a special namespace, etc.
1.21.0EditFilterMergedContentPost-section-merge edit filter
1.6.0EditFilterPerform checks on an edit
1.16EditFormInitialTextAllows modifying the edit form when editing existing pages
1.7.0EditFormPreloadTextCalled when edit page for anew article is shown. This lets you fill the text-box of a new page with initial wikitext.
1.25EditPage::attemptSave:afterCalled after an article save attempt
1.8.3EditPage::attemptSaveCalled before an article is saved, that is beforeinsertNewArticle() is called
1.16EditPage::importFormDataCalled when reading the data from the editform, after post
1.6.0EditPage::showEditForm:fieldsAllows injection of form field into edit form.
1.6.0EditPage::showEditForm:initialAllows injection of HTML into edit form
1.24EditPage::showReadOnlyForm:initialCalled just before the read only edit form is rendered
1.21.0EditPage::showStandardInputs:optionsAllows injection of form fields into the editOptions area
1.13.0EditPageBeforeConflictDiffAllows modifying the EditPage object and output when there's an edit conflict.
1.12.0EditPageBeforeEditButtonsUsed to modify the edit buttons on the edit form
1.16EditPageBeforeEditToolbarAllows modifying the edit toolbar above the textarea
1.16EditPageCopyrightWarningAllow for site and per-namespace customisation of contribution/copyright notice.
1.29EditPageGetCheckboxesDefinitionAllows modifying the edit checkboxes in the edit form
1.21EditPageGetDiffContentAllow modifying the wikitext that will be used inShow changes. Note that it is preferable to implement diff handling for different data types using theContentHandler facility.
1.21EditPageGetPreviewContentAllow modifying the wikitext that will be previewed. Note that it is preferable to implement previews for different data types using theContentHandler facility.
1.16EditPageNoSuchSectionWhen a section edit request is given for a non-existent section.
1.16EditPageTosSummaryGive a chance for site and per-namespace customisations of terms of service summary link that might exist separately from the copyright notice.
1.20FormatAutocommentsWhen an autocomment is formatted by the Linker.
1.19PlaceNewSectionOverride placement of new sections.
1.35ParserPreSaveTransformCompleteCalled fromParser::preSaveTransform() after processing is complete, giving the extension a chance to further modify the wikitext.
Page Rendering1.27.0AfterBuildFeedLinksExecuted after all feed links are created.
1.24AfterParserFetchFileAndTitleAlter the HTML code of an image gallery. Called after an image gallery is formed byParser, just before adding its HTML to parser output.
1.21ArticleContentViewCustom(removed in 1.35) Allows to output the text of the article in a different format than wikitext
1.6.0ArticlePageDataAfterExecutes after loading the data of an article from the database.
1.6.0ArticlePageDataBeforeExecutes before data is loaded for the article requested.
1.36ArticleParserOptionsThis hook is called before parsing wikitext for an article,
1.32ArticleRevisionViewCustomAllows to output the text of an article revision in a different format than wikitext
1.18ArticleViewFooterAfter showing the footer section of an ordinary page view.
1.6.0ArticleViewHeaderCalled after an articleheader is shown.
1.5.1ArticleViewRedirectAllows an extension to prevent the display of a "Redirected From" link on a redirect page.
1.7BadImageUsed to determine if an image exists on the 'bad image list'. Return false to when setting$bad value.
1.19BeforeDisplayNoArticleTextBefore displaying noarticletext or noarticletext-nopermission messages.
1.24BeforeHttpsRedirect(deprecated in 1.35) Called prior to forcing HTTP->HTTPS redirect. Use this hook to override how the redirect is output.
1.19BeforePageRedirectCalled prior to sending an HTTP redirect
1.18.0BeforeParserFetchFileAndTitleAllows an extension to select a different version of an image to link to.
1.10.1BeforeParserFetchTemplateAndtitle(deprecated in 1.36) Allows an extension to specify a version of a page to get for inclusion in a template.
1.36BeforeParserFetchTemplateRevisionRecordThis hook is called before a template is fetched by Parser.
1.10.1BeforeParserrenderImageGallery(deprecated in 1.35) Allows an extension to modify an image gallery before it is rendered.
1.22CanIPUseHTTPS(deprecated in 1.35) Called when checking if an IP address can use HTTPS
1.4.3CategoryPageViewCalled before viewing a categorypage inCategoryPage::view
1.25CategoryViewer::doCategoryQueryOccurs after querying for pages to be displayed in a Category page
1.25CategoryViewer::generateLinkBefore generating an output link allow extensions opportunity to generate a more specific or relevant link.
1.25ContentAlterParserOutputCustomise parser output for a given content object, called byAbstractContent::getParserOutput.
1.24.0ContentGetParserOutputCustomise parser output for a given content object, called byAbstractContent::getParserOutput. May be used to override the normal model-specific rendering of page content.
1.22.0GalleryGetModesAllows extensions to add classes that can render different modes of a gallery.
1.12GetLinkColoursModify the CSS class of an array of page links
1.28HtmlPageLinkRendererBeginargs = LinkRenderer $linkRenderer, LinkTarget $target, &$text, &$extraAttribs, &$query, &$ret
1.28HtmlPageLinkRendererEndargs = LinkRenderer $linkRenderer, LinkTarget $target, $isKnown, &$text, &$attribs, &$ret
1.13ImageBeforeProduceHTMLCalled before producing the HTML created by a wiki image insertion
1.11ImageOpenShowImageInlineBeforeFired just before showing the image on an image page.
1.16ImagePageAfterImageLinksCalled after the image links section on an image page is built.
1.13ImagePageFileHistoryLineCalled when a file history line is constructed.
1.13ImagePageFindFileCalled when fetching the file associated with an image page.
1.16ImagePageShowTOCCalled when fetching the file associed with an image page.
1.10.0InternalParseBeforeLinksUsed to process the expanded wiki code after‎<nowiki>, HTML-comments, and templates have been treated. Suitable for syntax extensions that want to customise the treatment of internal link syntax, i.e.[[....]].
1.20InternalParseBeforeSanitize(deprecated in 1.35) This hook is called during Parser'sinternalParse method just before the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/includeonly/onlyinclude and other processings.
1.13.0LinkerMakeExternalImageCalled before external image HTML is returned. Used for modifying external image HTML.
1.13.0LinkerMakeExternalLinkCalled before the HTML for external links is returned. Used for modifying external link HTML.
1.23.0LinkerMakeMediaLinkFileCalled before the HTML for media links is returned. Used for modifying media link HTML.
1.6.0OutputPageBeforeHTMLCalled every time wikitext is added to the OutputPage, after it is parsed but before it is added. Called after the page has been rendered, but before the HTML is displayed.
1.8.0OutputPageParserOutputCalled after parse, before the HTML is added to the output.
1.43OutputPageRenderCategoryLinkThis hook is called when a category link is rendered.
1.6.0PageRenderingHashAlter the parser cache option hash key.
1.20ParserAfterParseCalled fromParser::parse() just after the call toParser::internalParse() returns.
1.5.0ParserAfterStrip(removed in 1.36) Before version 1.14.0, used to process raw wiki code after text surrounded by‎<nowiki> tags have been protected but before any other wiki text has been processed. In version 1.14.0 and later, runs immediately after ParserBeforeStrip.
1.5.0ParserAfterTidyUsed to add some final processing to the fully-rendered page output.
1.26ParserAfterUnstripCalled after the first unstripGeneral() inParser::internalParseHalfParsed()
1.6.0ParserBeforeInternalParseReplaces the normal processing of stripped wiki text with custom processing. Used primarily to support alternatives (rather than additions) to the core MediaWiki markup syntax.
1.35ParserBeforePreprocessCalled at the beginning ofParser::preprocess()
1.5.0ParserBeforeStrip(removed in 1.36) Used to process the raw wiki code before any internal processing is applied.
1.5.0ParserBeforeTidy(removed in 1.36) Used to process the nearly-rendered html code for the page (but before any html tidying occurs).
1.26ParserCacheSaveCompleteModify ParserOutput safely after it has been saved to cache.
1.6.0ParserClearStateCalled at the end ofParser::clearState()
1.21.0ParserClonedCalled when the Parser object is cloned.
1.28ParserFetchTemplate(deprecated in 1.35) Called when the parser fetches a template
1.6.0ParserGetVariableValueSwitchAssigns a value to a user definedvariable.
1.6.0ParserGetVariableValueTsUse this to change the value of the time for the {{LOCAL...}} magic word.
1.6.0ParserGetVariableValueVarCache(deprecated in 1.35) Use this to change the value of the variable cache or return false to not use it.
1.35ParserFetchTemplateDataFetches template data for an array of template titles
1.22ParserLimitReportFormatCalled for each row in the parser limit report that needs formatting.
1.22ParserLimitReportPrepareCalled at the end ofParser:parse() when the parser will include comments about size of the text parsed.
1.39ParserLogLinterDataReport lints fromParsoid to theLinter extension
1.12ParserMakeImageParamsAlter the parameters used to generate an image before it is generated
1.38ParserModifyImageHTMLThis hook is called for each image added to parser output, with its associated HTML as returned fromLinker::makeImageLink().
1.30ParserOptionsRegisterAllows registering additional parser options
1.31ParserOutputPostCacheTransformCalled fromParserOutput::getText() to do post-cache transforms.
1.27ParserOutputStashForEditCalled when an edit stash parse finishes, before the output is cached.
1.35ParserPreSaveTransformCompleteCalled fromParser::preSaveTransform() after processing is complete, giving the extension a chance to further modify the wikitext.
1.19ParserSectionCreate(deprecated in 1.35) Called each time the parser creates a document section from wikitext.
1.26RejectParserCacheValueReturn false to reject an otherwise usable cached value from the Parser cache.
1.26ResourceLoaderForeignApiModulesCalled from ResourceLoaderForeignApiModule. Use this to add dependencies to mediawiki.ForeignApi module when you wish to override its behaviour. See the module docs for more information.
1.17ResourceLoaderGetConfigVarsCalled right beforeResourceLoaderStartUpModule::getConfig returns, to set static (not request-specific) configuration variables. Can not depend on current page, current user or current request; see below.
1.18ResourceLoaderGetStartupModulesRun once the startup module is being generated.
1.38ResourceLoaderExcludeUserOptionsExclude a user option from the preloaded data for client-sidemw.user.options.
1.29ResourceLoaderJqueryMsgModuleMagicWordsCalled in ResourceLoaderJqueryMsgModule to allow adding magic words for jQueryMsg. The key is an all-caps magic word, and the value is a string; values depend only on the ResourceLoaderContext
1.43ResourceLoaderModifyStartupSourceUrlsCalled in StartUpModule to allow modifying source URLs.
1.43ResourceLoaderModifyEmbeddedSourceUrlsAllows modifying source URLs (i.e. URLs toload.php) before they get embedded in the JS generated for the startup module.
1.17.0ResourceLoaderRegisterModulesAllows registering modules with ResourceLoader
1.35ResourceLoaderSiteModulePagesAllows to change which wiki pages comprise the`site` module in given skin.
1.35ResourceLoaderSiteStylesModulePagesAllows to change which wiki pages comprise the'site.styles' module in given skin.
1.19ResourceLoaderTestModules(deprecated in 1.33) Add new javascript test suites. This is called after the addition of MediaWiki core test suites.
1.24.0SidebarBeforeOutputDirectly before the sidebar is output
1.16ShowMissingArticleCalled when generating the output for a non-existent page.
User Interface1.18ActionBeforeFormDisplayBefore executing the HTMLForm object
1.18ActionModifyFormFieldsBefore creating an HTMLForm object for a page action; allows to change the fields on the form that will be generated.
1.20AfterFinalPageOutputNearly at the end ofOutputPage::output().
1.9.1AjaxAddScriptCalled in output page just before the initialisation
1.5.7ArticleEditUpdateNewTalkBefore updatinguser_newtalk when a user talk page was changed.
1.6.0ArticlePurgeExecutes before running&action=purge
1.32ArticleShowPatrolFooterCan be used to hide the[mark as patrolled] link in certain circumstances
1.18.0BeforeWelcomeCreationAllows an extension to change the message displayed upon a successful login.
1.32ContentSecurityPolicyDefaultSourceModify the allowed CSP load sources. This affects all directives except for the script directive.
1.32ContentSecurityPolicyDirectivesModify the content security policy directives.
1.32ContentSecurityPolicyScriptSourceModify the allowed CSP script sources.
1.4.0EmailUserCompleteOccurs after an email has been sent from one user to another
1.4.0EmailUserOccurs whenever the software receives a request to send an email from one user to another
1.41EmailUserAuthorizeSendCalled when checking whether a user is allowed to send emails
1.41EmailUserSendEmailCalled before sending an email, when all other checks have succeeded.
1.21GetHumanTimestampPre-emptively override the human-readable timestamp generated byMWTimestamp::getHumanTimestamp(). Return false in this hook to use the custom output.
1.31GetLangPreferredVariantAllows fetching the language variant code from cookies or other such alternative storage.
1.22GetNewMessagesAlertDisable or modify the new messages alert before it is shown
1.16GetPreferencesModify user preferences.
1.22GetRelativeTimestampPre-emptively override the relative timestamp generated byMWTimestamp::getRelativeTimestamp(). Return false in this hook to use the custom output.
1.32HistoryPageToolLinksAllows adding links to the revision history page subtitle.
1.21HistoryRevisionTools(deprecated in 1.35) Override or extend the revision tools available from the page history view, i.e. undo, rollback, etc.
1.35HistoryToolsUse this hook to override or extend the revision tools available from the page history view, i.e. undo, rollback, etc.
1.24LanguageSelectorHook to change the language selector available on a page.
1.6.0MarkPatrolledCompleteCalled after an edit is marked patrolled
1.6.0MarkPatrolledCalled before an edit is marked patrolled
1.14MakeGlobalVariablesScriptRight beforeOutputPage->getJSVars returns the vars.
1.32OutputPageAfterGetHeadLinksArrayAllows extensions to modify the HTML metadata in the‎<head> element
1.17OutputPageBodyAttributesCalled whenOutputPage::headElement() is creating the body tag.
1.14OutputPageCheckLastModifiedWhen checking if the page has been modified since the last visit
1.13OutputPageMakeCategoryLinksCalled when links are about to be generated for the page's categories.
1.10PageHistoryBeforeListWhen a history page list is about to be constructed.
1.10PageHistoryLineEndingRight before the end‎<li> is added to a history line.
1.26PageHistoryPager::doBatchLookupsAllow performing batch lookups for prefetching information needed for display
1.13PageHistoryPager::getQueryInfoWhen a history pager query parameter set is constructed.
1.10RawPageViewBeforeOutputCalled before displaying a page withaction=raw. Returnstrue if display is allowed,false if display is not allowed.
1.16ShowSearchHitTitleCustomise display of search hit title/link.
1.21ShowSearchHitCustomise display of search hit.
1.7SiteNoticeAfterUsed to modify the site notice after it has been created from$wgSiteNotice or interface messages.
1.7SiteNoticeBeforeUsed to modify thesitenotice before it has been created from $wgSiteNotice. Return false to suppress or modify default site notice.
1.6.0SpecialMovepageAfterMoveCalled after a page is moved.
1.34UndeletePageToolLinksAdd one or more links to edit page subtitle when a page has been previously deleted.
1.4.0UnwatchArticleCompleteOccurs after the unwatch article request has been processed
1.4.0UnwatchArticleOccurs whenever the software receives a request to unwatch an article
1.5.7UserClearNewTalkNotificationCalled when clearing the "You have new messages!" message, return false to not delete it
1.4.0UserLoginCompleteOccurs after a user has successfully logged in
1.4.0UserLogoutCompleteOccurs after a user has successfully logged out
1.4.0UserLogoutOccurs when the software receives a request to log out
1.5.7UserRetrieveNewTalks(deprecated in 1.35) Called when retrieving "You have new messages!" message(s)
1.19UserToolLinksEditCalled when generating a list of user tool links, eg"Foobar (talk | contribs | block)"
1.4.0WatchArticleCompleteOccurs after the watch article request has been processed
1.4.0WatchArticleOccurs whenever the software receives a request to watch an article
File Management1.19BitmapHandlerCheckImageAreaCalled byBitmapHandler::normaliseParams(), after all normalisations have been performed, except for the$wgMaxImageArea check.
1.18BitmapHandlerTransformBefore a file is transformed, gives extension the possibility to transform it themselves.
1.13FileDeleteCompleteWhen a file is deleted.
1.20FileTransformedWhen a file is transformed and moved into storage.
1.13FileUndeleteCompleteWhen a file is undeleted.
1.11FileUploadFires when a local file upload occurs.
1.18GetMetadataVersionAllows to modify the image metadata version currently in use.
1.23.0GetExtendedMetadataAllows including additional file metadata information in the imageinfo API.
1.24HTMLFileCache::useFileCacheOverride whether a page should be cached in file cache.
1.10.0IsFileCacheableAllow an extension to disable file caching on pages.
1.22IsUploadAllowedFromUrlAllows overriding the result ofUploadFromUrl::isAllowedUrl().
1.16.0ImgAuthBeforeStreamExecuted before file is streamed to user, but only when using img_auth
1.34ImgAuthModifyHeadersExecuted just before a file is streamed to a user, allowing headers to be modified beforehand.
1.13LocalFile::getHistoryCalled before file history query performed.
1.19LocalFilePurgeThumbnailsCalled before thumbnails for a local file are purged.
1.21ThumbnailBeforeProduceHTMLCalled before an image HTML is about to be rendered (by ThumbnailImage:toHtml method).
1.16UploadCreateFromRequestWhenUploadBase::createFromRequest has been called.
1.9.0UploadForm:BeforeProcessingCalled just before the file data (for example description) are processed, so extensions have a chance to manipulate them.
1.31UploadForm:getInitialPageTextAfter the initial page text for file uploads is generated, to allow it to be altered.
1.16UploadFormInitDescriptorOccurs after the descriptor for the upload form has been assembled.
1.16UploadFormSourceDescriptorsOccurs after the standard source inputs have been added to the descriptor.
1.28UploadStashFileOccurs before a file is stashed (uploaded to stash).
1.6.4UploadCompleteCalled when a file upload has completed.
1.17UploadVerifyFileCalled when a file is uploaded, to allow extra file verification to take place
1.28UploadVerifyUpload(preferred) Can be used to reject a file upload. Unlike 'UploadVerifyFile' it provides information about upload comment and the file description page, but does not run for uploads to stash.
1.23ValidateExtendedMetadataCacheCalled to validate the cached metadata inFormatMetadata::getExtendedMeta (returnfalse means cache will be invalidated and theGetExtendedMetadata hook will called again).
1.18XMPGetInfoCalled when obtaining the list of XMP tags to extract.
1.18XMPGetResultsCalled just before returning the results array of parsing xmp data.
Special pages1.32AncientPagesQueryAllows modifying the query used bySpecial:AncientPages.
1.9.1BookInformationHook to allow extensions to insert additional HTML to a list of book sources e.g. for API-interacting plugins and so on.
1.23ChangesListInitRowsBatch process change list rows prior to rendering.
1.12ChangesListInsertArticleLinkOverride or augment link to article in RC list.
1.44ChangesListInsertLogEntryUse this hook to override or modify the line for a log entry in a RC list.
1.23ChangesListSpecialPageFiltersCalled after building form options on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist).
1.24ChangesListSpecialPageQueryCalled when building SQL query on pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked and Watchlist).
1.29ChangesListSpecialPageStructuredFiltersCalled to allow extensions to register filters for pages inheriting from ChangesListSpecialPage (in core: RecentChanges, RecentChangesLinked, and Watchlist).
1.13ContribsPager::getQueryInfoCalled before the contributions query is about to run.
1.20ContribsPager::reallyDoQueryCalled before really executing the query forSpecial:Contributions.
1.13ContributionsLineEndingCalled before an HTML line forSpecial:Contributions is finished.
1.11ContributionsToolLinksChange tool links above Special:Contributions.
1.24DeletedContribsPager::reallyDoQueryCalled before really executing the query for Special:DeletedContributions.
1.24DeletedContributionsLineEndingCalled before an HTML line forSpecial:DeletedContributions is finished.
1.17EmailUserCCOccurs before sending the copy of the email to the author.
1.17EmailUserFormOccurs after building the email user form object.
1.16EmailUserPermissionsErrorsRetrieve permissions errors for emailing a user.
1.25EnhancedChangesList::getLogTextAllows altering, removing or adding to the links of a group of changes in EnhancedChangesList.
1.26EnhancedChangesListModifyBlockLineDataModify data used to build a non-grouped entry in Special:RecentChanges.
1.26EnhancedChangesListModifyLineDataModify data used to build a grouped recent change inner line in Special:RecentChanges.
1.7FetchChangesListAllows extension to modify a recent changes list for a user.
1.20GitViewersCalled when generating the list of git viewers for Special:Version, use this to change the list.
1.30NewPagesLineEndingCalled before an HTML line forSpecial:NewPages is finished.
1.23LonelyPagesQueryAllows modifying the query used bySpecial:LonelyPages.
1.36LinkerGenerateRollbackLinkcalled before a rollback link is displayed, and after all checks have been performed
1.14OldChangesListRecentChangesLineCustomise entire Recent Changes line.
1.23PreferencesFormPreSaveAllows last minute changes to a user's preferences (viaUser#setOption) before they're saved and gives a possibility to check which options were modified.
1.40PreferencesGetIconAdd icons that will be displayed in the mobile layout ofSpecial:Preferences.
1.40PreferencesGetLayoutIndicate whether the preferences will have a mobile or desktop layout.
1.19PreferencesGetLegendOverride the text used for the‎<legend> of a preferences section.
1.26RandomPageQueryModify the query used by Special:Random.
1.20RedirectSpecialArticleRedirectParamsLets you alter the set of parameter names such as "oldid" that are preserved when using redirecting special pages such asSpecial:MyPage andSpecial:MyTalk.
1.27ShortPagesQueryAllow extensions to modify the query used bySpecial:ShortPages.
1.24.0SpecialBlockModifyFormFieldsAdd or modify block fields of Special:Block.
1.27SpecialContributions::getForm::filtersCalled with a list of filters to render onSpecial:Contributions.
1.28.0SpecialContributions::formatRow::flagsCalled before rendering a Special:Contributions row.
1.5.0SpecialContributionsBeforeMainOutputBefore the form on Special:Contributions
1.40SpecialCreateAccountBenefitsReplace the default signup page content about the benefits of registering an account ("Wikipedia is made by people like you...") on Special:CreateAccount.
1.38SpecialExportGetExtraPagesAdd extra pages to the list of pages to export.
1.13.0SpecialListusersDefaultQueryCalled right before the end ofUsersPager::getDefaultQuery().
1.13.0SpecialListusersFormatRowCalled right before the end ofUsersPager::formatRow().
1.13.0SpecialListusersHeaderFormCalled before adding the submit button inUsersPager::getPageHeader().
1.13.0SpecialListusersHeaderCalled before closing the‎<fieldset> inUsersPager::getPageHeader()
1.13.0SpecialListusersQueryInfoCalled right before the end ofUsersPager::getQueryInfo()
1.34SpecialMuteModifyFormFieldsAllows modifying HTMLForm fields forSpecial:Mute
1.34SpecialMuteSubmit(deprecated in 1.34) Used only for instrumentation onSpecialMute
1.17SpecialNewpagesConditionsCalled when building the SQL query forSpecial:NewPages.
1.18SpecialNewPagesFiltersCalled after building form options atSpecial:NewPages.
1.7.0SpecialPage_initListCalled after the Special Page list is populated
1.20SpecialPageAfterExecuteCalled afterSpecialPage::execute().
1.20SpecialPageBeforeExecuteCalled beforeSpecialPage::execute().
1.24SpecialPageBeforeFormDisplayBefore executing the HTMLForm object
1.18SpecialPasswordResetOnSubmitCalled when executing a form submission onSpecial:PasswordReset.
1.42SpecialPrefixIndexGetFormFilterscalled with a list of filters to render onSpecial:PrefixIndex
1.42SpecialPrefixIndexQueryUse this hook to modify the query used bySpecial:PrefixIndex.
1.16SpecialRandomGetRandomTitleModify the selection criteria forSpecial:Random
1.13SpecialRecentChangesPanelCalled when building form options in SpecialRecentChanges.
1.22SpecialResetTokensTokensCalled when building token list for SpecialResetTokens.
1.19.0SpecialSearchCreateLinkCalled when making the message to create a page or go to an existing page
1.6.0SpecialSearchNogomatchCalled when the 'Go' feature is triggered and the target doesn't exist. Full text search results are generated after this hook is called
1.19.0SpecialSearchPowerBoxThe equivalent of SpecialSearchProfileForm for the advanced form
1.27SpecialSearchGoResultCalled before the 'go' feature of SpecialSearch redirects a user. May provide it's own URL to redirect to.
1.18SpecialSearchProfileFormAllows modification of search profile forms
1.16SpecialSearchProfilesAllows modification of search profiles.
1.21SpecialSearchResultsAppendCalled after all search results HTML has been output. Note that in some cases, this hook will not be called (no results, too many results, SpecialSearchResultsPrepend returned false, etc).
1.21SpecialSearchResultsPrependSpecialSearchResultsPrepend: Called immediately before returning HTML on the search results page. Useful for including an external search provider. To disable the output of MediaWiki search output, return false.
1.13SpecialSearchResultsCalled before search result display when there are matches
1.18SpecialSearchSetupEngineAllows passing custom data to search engine
1.16SpecialStatsAddExtraCan be used to add extra statistic at the end ofSpecial:Statistics.
1.29SpecialTrackingCategories::generateCatLinkCalled for each category link onSpecial:TrackingCategories
1.29SpecialTrackingCategories::preprocessCalled after LinkBatch onSpecial:TrackingCategories
1.16SpecialUploadCompleteCalled after successfully uploading a file fromSpecial:Upload
1.45SpecialUserRightsChangeableGroupscalled on checking changeable groups in SpecialUserRights
1.21SpecialVersionVersionUrlCalled when building the URL forSpecial:Version.
1.22SpecialWatchlistGetNonRevisionTypes(deprecated in 1.45) Allows extensions to register the value they have inserted to rc_type field of recentchanges for non-revision changes so they can be included in the watchlist.
1.26SpecialWhatLinksHereLinksCalled every time a list of links is built for a list item for Special:WhatLinksHere.
1.43SpecialWhatLinksHereQueryUse this hook to modify the query used bySpecial:WhatLinksHere.
1.18UndeleteForm::showHistoryCalled inUndeleteForm::showHistory, after a PageArchive object has been created but before any further processing is done.
1.18UndeleteForm::showRevisionCalled inUndeleteForm::showRevision, after a PageArchive object has been created but before any further processing is done.
1.18UndeleteForm::undeleteCalled inUndeleteForm::undelete, after checking that the site is not in read-only mode, that the Title object is notnull and after a PageArchive object has been constructed but before performing any further processing.
1.9UndeleteShowRevision(deprecated in 1.35) Called when showing a revision in Special:Undelete.
1.9.0UploadForm:initialCalled just before the upload form is generated
1.28UsersPagerDoBatchLookupsGive extensions providing user group data from an alternate source a chance to add their data into the cache array so that things like global user groups are displayed correctly inSpecial:ListUsers.
1.18WantedPages::getQueryInfoCalled inWantedPagesPage::getQueryInfo(), can be used to alter the SQL query which gets the list of wanted pages.
1.24WatchlistEditorBeforeFormRenderOccurs before building theSpecial:EditWatchlist form, used to manipulate the list of pages or preload data based on that list.
1.17WatchlistEditorBuildRemoveLineOccurs when building remove lines in Special:Watchlist/edit.
1.24.0WhatLinksHerePropsAllows extensions to annotate WhatLinksHere entries.
1.40ContributeCardsFired on Special:Contribute page to allow extensions to add "card" entry points.
User Management1.13AbortAutoblockAllow extension to cancel an autoblock.
1.20AbortEmailNotificationCan be used to cancel email notifications for an edit.
1.22AbortTalkPageEmailNotificationDisable email notifications of edits to users' talk pages.
1.5.0AddNewAccount(deprecated in 1.27) Called after a user account is created
1.43AuthenticationAttemptThrottledcalled when aMediaWiki\Auth\Throttler has throttled an authentication attempt.
1.43AuthManagerFilterProvidersAllow disabling authentication providers.
1.27AuthManagerLoginAuthenticateAuditA login attempt either succeeded or failed for a reason other than misconfiguration or session loss. No return data is accepted; this hook is for auditing only.
1.43AuthManagerVerifyAuthenticationCalled before the end of a successful login or account creation attempt.
1.13AuthPluginAutoCreate(deprecated in 1.27) Called when creating a local account for a user logged in from an external authentication method.
1.9.1AuthPluginSetup(deprecated in 1.27) Update or replace authentication plugin object ($wgAuth).
1.43AuthPreserveQueryParamsUsed when an authentication page generates a URL which is in some sense part of the authentication process
1.12AutopromoteCondition(deprecated in 1.46) Check autopromote condition for user.
1.32BeforeResetNotificationTimestampAllows prevention of clearing of notification timestamp when a user views a page in their watchlist.
1.4.0BlockIpCompleteOccurs after the request to block (or change block settings of) an IP or user has been processed
1.4.0BlockIpOccurs whenever the software receives a request to block (or change the block settings of) an IP address or user
1.27ChangeAuthenticationDataAuditCalled when user changes authentication data.
1.29.0ChangeUserGroupsCalled before a user's group memberships are changed
1.43ConditionalDefaultOptionsAddConditionThis hook is called when ConditionalDefaultsLookup service is created.
1.16ConfirmEmailCompleteCalled after a user's email has been confirmed successfully.
1.31DeleteUnknownPreferencesCalled by the cleanupPreferences.php maintenance script to build a WHERE clause with which to delete preferences that are not known about.
1.7EmailConfirmedReplace default way to check whether user's email is confirmed.
1.19ExemptFromAccountCreationThrottleTo add an exemption from the account creation throttle.
1.37GetAllBlockActionsAdd an action that can be blocked via a partial block.
1.40GetBlockErrorMessageKeyAllows extensions to override the message that will be displayed to the user.
1.6.0GetBlockedStatus(removed in 1.35) Fired after the user's getBlockStatus is set
1.34GetUserBlockModify the block found by the block manager.
1.12getUserPermissionsErrorsAdd a permissions error when permissions errors are checked for.
1.12getUserPermissionsErrorsExpensiveSame asgetUserPermissionsErrors as but called only if expensive checks are enabled.
1.13GetAutoPromoteGroupsWhen determining which autopromote groups a user is entitled to be in.
1.16InvalidateEmailCompleteCalled after a user's email has been invalidated successfully.
1.9IsTrustedProxyAllows an extension to set an IP as trusted or not.
1.12isValidEmailAddrOverride the result ofSanitizer::validateEmail().
1.11isValidPasswordOverride the result ofUser::isValidPassword().
1.26.0LocalUserCreatedCalled immediately after a local user has been created and saved to the database.
1.45LocalUserOptionsStoreSavecalled just after saving preferences inMediaWiki\User\Options\LocalUserOptionsStore
1.37LoadUserOptionsThis hook is called when user options/preferences are being loaded from the database.
1.26PasswordPoliciesForUserAlter the effective password policy for a user.
1.18PerformRetroactiveAutoblockCalled before a retroactive autoblock is applied to a user.
1.39PermissionErrorAuditCalled after permission checks to allow logging.
1.44PermissionStatusAuditallows making any permission status (even if it has no errors) available to consumers
1.9PingLimiterAllows extensions to override the results ofUser::pingLimiter().
1.11PrefsEmailAuditCalled when user changes his email address.
1.23ResetPasswordExpirationAllow extensions to set a default password expiration.
1.40RenameUserAbortAllow other extensions to abort a user rename
1.40RenameUserCompleteAfter a sucessful user rename
1.40RenameUserPreRenameBefore renaming a user
1.40RenameUserWarningGet warnings when renaming a user
1.37SaveUserOptionsCalled just before saving user preferences. This hook replacesUserSaveOptions. Hook handlers can either add or manipulate options, or reset one back to its default to block changing it. Hook handlers are also allowed to abort the process by returningfalse, e.g. to save to a global profile instead. Compare to theUserSaveSettings hook, which is called after the preferences have been saved.
1.27.0SecuritySensitiveOperationStatusAffect the return value fromAuthManager::securitySensitiveOperationStatus()
1.27.0SessionCheckInfoValidate session info as it's being loaded from storage
1.27.0SessionMetadataAdd metadata to a session being saved
1.43.0SpreadAnyEditBlockOccurs whenUser::spreadAnyEditBlock is called, used to allow autoblocking for non-core blocking mechanisms.
1.39TempUserCreatedRedirectThis hook is called after an action causes a temporary user to be created. The handler may modify the redirect URL.
1.21UpdateUserMailerFormattedPageStatusOccurs before a notification email gets sent.
1.29.0UnblockUserCompleteOccurs after the request to unblock an IP or user has been processed
1.29.0UnblockUserOccurs whenever the software receives a request to unblock an IP address or user
1.14User::mailPasswordInternalBefore creation and mailing of a user's new temporary password.
1.18UserAddGroupCalled when adding a group to a user.
1.13UserArrayFromResultCalled when creating a UserArray object from a database result.
1.6.0userCanTo interrupt/advise the "user can do X to Y article" check
1.12UserCanSendEmailAllows overriding the permission check inUser::canSendEmail().
1.38UserEditCountUpdateThis is called from a deferred update on edit or move and provides collected user edit count information.
1.11UserEffectiveGroupsDynamically add or remove to the default user groups provided by the database tableuser_groups.
1.13UserGetAllRightsAfter calculating a list of all available rights.
1.18UserGetDefaultOptionsCalled after fetching the core default user options.
1.13UserGetEmailAuthenticationTimestampCalled when getting the timestamp of email authentification.
1.13UserGetEmailCalled when getting a user email address.
1.18UserGetLanguageObjectCalled when getting user's interface language object.
1.14UserGetReservedNamesAllows to modify$wgReservedUsernames at run time.
1.32.0UserGetRightsRemoveCalled inUser::getRights() to dynamically remove rights
1.11.0UserGetRightsCalled inUser::getRights() to dynamically add rights
1.26UserGroupsChangedCalled after user groups are changed.
1.16UserIsBlockedFromCheck if a user is blocked from a specific page (for specific block exemptions).
1.14UserIsBlockedGlobally(deprecated in 1.40) Runs beforeUser::mBlockedGlobally is set; can be used to change the blocked status of an IP address or a user
1.28UserIsBotOccurs when determining whether a user is a bot account.
1.26.0UserIsLockedFired to check if a user account is locked
1.22UserIsEveryoneAllowedCheck if all users are allowed some user right; returnfalse if aUserGetRights hook might remove the named right.
1.26UserIsHidden(removed in 1.35) Check if the user's name should be hidden. SeeUser::isHidden().
1.45UserLinkRendererUserLinkPostRendercalled after the username link HTML has been generated
1.14UserLoadAfterLoadFromSessionCalled to authenticate users on external/environmental means; occurs after session is loaded.
1.13UserLoadDefaultsCalled when loading a default user.
1.15UserLoadFromDatabaseCalled when loading a user from the database.
1.16UserLoadOptionsWhen user options/preferences are being loaded from the database.
1.27.0UserLoggedInCalled after a user is logged in
1.27UserMailerSplitToCalled inUserMailer::send() to give extensions a chance to split up an email with multiple of theTo: field into separate emails.
1.27UserMailerTransformContentAllow transformation of content, such as encrypting/signing.
1.27UserMailerTransformMessageCalled inUserMailer::send() to change email after it has gone through the MIME transform. Extensions can block sending the email by returningfalse and setting $error.
1.41UserPrivilegedGroupsUse this hook to extend what MediaWiki considers to be a "privileged group" beyond the values set in$wgPrivilegedGroups
1.18UserRemoveGroupCalled when removing a group from a user.
1.46UserRequirementsConditionCheck condition for user.
1.22UserRequiresHTTPS(deprecated in 1.35) Allows extensions to override whether users need to be redirected to HTTPS.
1.24UserResetAllOptionsAllows changing the behaviour when a user's preferences are reset. For instance, certain preferences can be preserved.
1.16UserSaveOptionsCalled just before saving user preferences. Hook handlers can either add or manipulate options, or reset one back to its default to block changing it. Hook handlers are also allowed to abort the process by returningfalse, e.g. to save to a global profile instead. Compare to theUserSaveSettings hook, which is called after the preferences have been saved.
1.13UserSaveSettingsCalled directly after user preferences (user_properties in the database) have been saved. Compare to theUserSaveOptions hook, which is called before.
1.33UserSendConfirmationMailCalled just before a confirmation email is sent to a user. Hook handlers can modify the email that will be sent.
1.13UserSetCookies(deprecated in 1.27) Called when setting user cookies.
1.13UserSetEmailAuthenticationTimestampCalled when setting the timestamp of email authentication.
1.13UserSetEmailCalled when changing user email address.
Logging1.23GetLogTypesOnUserAdd log types where the target is a userpage.
1.45GetSecurityLogContextUsed to collect information about the request that's worth logging for log events which are relevant for security or anti-abuse purposes (login, credentials changes etc).
1.26.0LogExceptionCalled before an exception (or PHP error) is logged.
1.25LogEventsListGetExtraInputsWhen getting extra inputs to display on Special:Log for a specific log type.
1.30LogEventsListLineEndingCalled before an HTML line forSpecial:Log is finished.
1.19LogEventsListShowLogExtractCalled before the result ofLogEventsList::showLogExtract() is added to OutputPage.
1.12LogLineProcesses a single log entry on Special:Log.
1.33ManualLogEntryBeforePublishLets extensions tag log entries when actions are performed.
1.29OtherAutoblockLogLinkGet links to the autoblock log from extensions which autoblocks users and/or IP addresses too..
1.16OtherBlockLogLinkGet links to the block log from extensions which blocks users and/or IP addresses too.
1.24SpecialLogAddLogSearchRelationsAdd log relations to the current log.
1.45SpecialLogResolveLogTypeHook for intercepting and changing the requested log type inSpecial:Log, for example, in order to intercept an alias for the log type and change it to the canonical name.
Skinning / Templates1.27.0AuthChangeFormFieldsAllows modification of AuthManager-based forms
1.23.0BaseTemplateAfterPortlet(deprecated in 1.35) (SkinTemplate.php) After rendering of portlets.
1.18BaseTemplateToolbox(deprecated in 1.35) Called by BaseTemplate when building the toolbox array and returning it for the skin to output.
1.7.0BeforePageDisplayAllows last minute changes to the output page, e.g. adding of CSS or JavaScript by extensions.
1.25.0LoginFormValidErrorMessagesAllows to add additional error messages (SpecialUserLogin.php).
1.7.0PersonalUrls(SkinTemplate.php) Called after the list ofpersonal URLs (links at the top in Monobook) has been populated.
1.24.0PostLoginRedirect(SpecialUserlogin.php) Modify the post login redirect behaviour.
1.19RequestContextCreateSkinCalled when creating a skin instance.
1.35SkinAddFooterLinksAdd items to the footer for skins using SkinAddFooterLinks.
1.11.0SkinAfterBottomScripts(Skin.php) At the end ofSkin::bottomScripts()
1.14SkinAfterContentAllows extensions to add text after the page content and article metadata.
1.35SkinAfterPortletOccurs whenever a page is rendered and allows to add HTML after portlets have been put out.
1.14SkinBuildSidebarAt the end ofSkin::buildSidebar().
1.16SkinCopyrightFooterAllow for site and per-namespace customisation of copyright notice.
1.43SkinCopyrightFooterMessageUse this hook for site and per-namespace customization of the copyright notice as wikitext.
1.25SkinEditSectionLinksModify the section edit links. Called when section headers are created.
1.17SkinGetPoweredBy(deprecated in 1.37) Called when generating the code used to display the "Powered by MediaWiki" icon.
1.36SkinPageReadyConfigAllows skins to change the `mediawiki.page.ready` module configuration.
1.24SkinPreloadExistenceModify the CSS class of an array of page links.
1.12.0SkinSubPageSubtitle(Skin.php) Called before the list of subpage links on top of a subpage is generated
1.6.0SkinTemplateBuildNavUrlsNav_urlsAfterPermalink(deprecated in 1.35) Called after thepermalink has been entered in navigation URL array.
1.23.0SkinTemplateGetLanguageLinkCalled after building the data for a language link from which the actual html is constructed.
1.18.0SkinTemplateNavigation::SpecialPage(usage discouraged)

Called on special pages after the special tab is added but before variants have been added

1.18.0SkinTemplateNavigation::Universal(usage discouraged)

Called on both content and special pages after variants have been added

1.16.0SkinTemplateNavigationCalled on content pages only after tabs have been added, but before variants have been added. See the other two SkinTemplateNavigation hooks for other points tabs can be modified at.
1.10SkinTemplateOutputPageBeforeExec(deprecated in 1.35) Allows further setup of the template engine after all standard setup has been performed but before the skin has been rendered.
1.6.0SkinTemplatePreventOtherActiveTabs(deprecated in 1.35) Called to enable/disable the inclusion of additional tabs to the skin.
1.12SkinTemplateTabAction(deprecated in 1.35) OverrideSkinTemplate::tabAction().
1.13SkinTemplateToolboxEnd(deprecated in 1.35) Called by SkinTemplate skins after toolbox links have been rendered (useful for adding more).
API1.14.0APIAfterExecuteUse this hook to extend core API modules
1.23.0ApiBeforeMainCalled before ApiMain is executed
1.20ApiCheckCanExecuteCalled duringApiMain::checkCanExecute().
1.29ApiDeprecationHelpAdd messages to the 'deprecation-help' warning generated fromApiBase::addDeprecation().
1.25ApiFormatHighlightUse to syntax-highlight API pretty-printed output. When highlighting, add output to$context->getOutput() and returnfalse.
1.14.0APIGetAllowedParamsUse this hook to modify a module's parameters
1.25APIGetDescriptionMessagesAllows to modify a module's help message.
1.25APIGetParamDescriptionMessagesAllows to modify a module's parameter descriptions.
1.25APIHelpModifyOutputAllows to modify an API module's help output.
1.43ApiLogFeatureUsageCalled after calling the logFeatureUsage() method of an API module
1.25ApiMain::moduleManagerCan be used to conditionally register API modules.
1.20ApiMain::onExceptionCalled byApiMain::executeActionWithErrorHandling() when an exception is thrown during API action execution.
1.28ApiMakeParserOptionsAllows extensions to adjust the parser options before parsing.
1.32ApiMaxLagInfoCalled right before giving out information about max lag in API.
1.25.0ApiOpenSearchSuggestCalled when constructing the OpenSearch results. Hooks can alter or append to the array.
1.33ApiOptionsCalled by action=options before applying changes to user preferences.
1.32ApiParseMakeOutputPageCalled when preparing the OutputPage object for ApiParse. This is mainly intended for callingOutputPage::addContentOverride() orOutputPage::addContentOverrideCallback().
1.25ApiQuery::moduleManagerCalled when ApiQuery has finished initialising its module manager.
1.14.0APIQueryAfterExecuteUse this hook to extend core API query modules
1.28ApiQueryBaseAfterQueryCalled for (some) API query modules after the database query has returned.
1.28ApiQueryBaseBeforeQueryCalled for (some) API query modules before a database query is made.
1.28ApiQueryBaseProcessRowCalled for (some) API query modules as each row of the database result is processed.
1.44ApiQueryCheckCanExecutecalled during the beginning ofApiQuery::execute()
1.14.0APIQueryGeneratorAfterExecuteUse this hook to extend core API query modules
1.13.0APIQueryInfoTokens(removed in 1.36) Use this hook to add custom tokens to prop=info
1.14.0APIQueryRecentChangesTokens(removed in 1.36) Use this hook to add custom tokens to list=recentchanges
1.13.0APIQueryRevisionsTokens(removed in 1.36) Use this hook to add custom tokens to prop=revisions
1.18APIQuerySiteInfoGeneralInfoUsed to add extra information to the SiteInfo general information output.
1.22APIQuerySiteInfoStatisticsInfoUsed to add extra information to the SiteInfo statistics information output.
1.24ApiQueryTokensRegisterTypesUse this hook to add additional token types to action=query&meta=tokens. Note that most modules will probably be able to use the 'csrf' token instead of creating their own token types.
1.15APIQueryUsersTokens(removed in 1.36) Use this hook to add custom token to list=users.
1.29ApiQueryWatchlistExtractOutputDataExtract row data for ApiQueryWatchlist.
1.29ApiQueryWatchlistPrepareWatchedItemQueryServiceOptionsPopulate the options to be passed from ApiQueryWatchlist to WatchedItemQueryService.
1.17ApiRsdServiceApisAdd or remove APIs from theRSD services list.
1.20ApiTokensGetTokenTypes(removed in 1.36) Use this hook to extend action=tokens with new token types.
1.29ApiValidatePasswordThis will allow for checking passwords against the wiki's password.
1.23.0AddNewAccountApiForm(deprecated in 1.27) Allows modifying the internal login form when creating an account via the API.
1.23.0AddNewAccountApiResult(deprecated in 1.27) Modifies the API output when an account is created via the API.
1.44RestCheckCanExecuteCalled when initializing a REST API request.
Import/Export1.17.0AfterImportPageWhen a page import is completed
1.17.0ImportHandleLogItemXMLTagWhen parsing a XML tag in a log item
1.17.0ImportHandlePageXMLTagWhen parsing a XML tag in a page
1.17.0ImportHandleRevisionXMLTagWhen parsing a XML tag in a page revision
1.17.0ImportHandleToplevelXMLTagWhen parsing a top level XML tag
1.31ImportHandleUnknownUserWhen a user doesn't exist locally, this hook is called to give extensions an opportunity to auto-create it. If the auto-creation is successful, returnfalse.
1.17.0ImportHandleUploadXMLTagWhen parsing a XML tag in a file upload
1.27ImportLogInterwikiLinkHook to change the interwiki link used in log entries and edit summaries for transwiki imports.
1.27ImportSourcesCalled when reading from the$wgImportSources configuration variable.
1.16.0ModifyExportQueryModify the query used by the exporter.
1.15.0WikiExporter::dumpStableQueryGet the SELECT query for "stable" revisions dumps
1.16.0XmlDumpWriterOpenPageCalled at the end ofXmlDumpWriter::openPage, to allow extra metadata to be added.
1.16.0XmlDumpWriterWriteRevisionCalled at the end of a revision in an XML dump, to add extra metadata.
Diffs1.14AbortDiffCacheCan be used to cancel the caching of a diff
1.17ArticleContentOnDiffBefore showing the article content below a diff.
1.29DifferenceEngineAfterLoadNewTextCalled inDifferenceEngine::loadNewText() after the new revision's content has been loaded into the class member variable.
1.29DifferenceEngineLoadTextAfterNewContentIsLoadedCalled inDifferenceEngine::loadText() after the new revision's content has been loaded into the class member variable$differenceEngine->mNewContent but before checking if the variable's value isnull.
1.29DifferenceEngineMarkPatrolledLinkAllow extensions to change the markpatrolled link, which is shown both on the diff header as well as on the bottom of a page, usually wrapped in a‎<span> element which hasclass="patrollink".
1.29DifferenceEngineMarkPatrolledRCIDAllows extensions to possibly change the rcid parameter.
1.29DifferenceEngineNewHeaderAllows extensions to change the $newHeader variable, which contains information about the new revision, such as the revision's author, whether.
1.29DifferenceEngineOldHeaderNoOldRevChange the $oldHeader variable in cases when there is no old revision.
1.29DifferenceEngineOldHeaderAllows extensions to change the $oldHeader variable, which contains information about the old revision, such as the revision's author, whether the revision was marked as a minor edit or not, etc.
1.29DifferenceEngineRenderRevisionAddParserOutputAllows extensions to change the parser output. Returnfalse to not add parser output via OutputPage's addParserOutput method.
1.29DifferenceEngineRenderRevisionShowFinalPatrolLinkAn extension can hook into this hook point and returnfalse to not show the final "mark as patrolled" link on the bottom of a page.
1.29DifferenceEngineShowDiffPageMaybeShowMissingRevisionCalled inDifferenceEngine::showDiffPage() when revision data cannot be loaded.
1.29DifferenceEngineShowDiffPageAdd additional output via the available OutputPage object into the diff view.
1.29DifferenceEngineShowDiffAllows extensions to affect the diff text which eventually gets sent to the OutputPage object.
1.29DifferenceEngineShowEmptyOldContentAllows extensions to change the diff table body (without header) in cases when there is no old revision or the old and new revisions are identical.
1.35DifferenceEngineViewHeaderCalled before displaying a diff.
1.21DiffRevisionTools(deprecated in 1.35) Override or extend the revision tools available from the diff view, i.e. undo, etc.
1.35DiffToolsUse this hook to override or extend the revision tools available from the diff view, i.e. undo, etc.
1.7DiffViewHeader(deprecated in 1.35) Called before diff display.
1.25.0GetDifferenceEngineAllows custom difference engine extensions such asExtension:WikEdDiff.
1.21EditPageGetDiffContentAllow modifying the wikitext that will be used in "Show changes". Note that it is preferable to implement diff handling for different data types using the ContentHandler facility.
1.15NewDifferenceEngineCalled when a new DifferenceEngine object is made.
1.32GetSlotDiffRendererReplace or wrap the standard SlotDiffRenderer for some content type.
1.41TextSlotDiffRendererTablePrefixAllows to change the HTML that is included in a prefix container directly before the diff table
Miscellaneous1.19.0AlternateUserMailerCalled before mail is sent so that mail could be logged (or something else) instead of using PEAR or PHP'smail().
1.6.0ArticleEditUpdatesDeleteFromRecentchanges(deprecated in 1.35) Occurs before saving to the database.
1.19BacklinkCacheGetConditionsAllows to set conditions for query when links to certain title.
1.19BacklinkCacheGetPrefixAllows to set prefix for a specific link table.
1.16BeforeInitializeOccurs before anything is initialised inMediaWiki::performRequest().
1.36BeforeRevertedTagUpdateThis hook is called before scheduling aRevertedTagUpdateJob.
1.21.0CategoryAfterPageAddedCalled after a page is added to a category
1.21.0CategoryAfterPageRemovedCalled after a page is removed from a category
1.19.0Collation::factoryAllows extensions to register new collation names, to be used with$wgCategoryCollation
1.8.0DisplayOldSubtitleAllows extensions to modify the displaying of links to other revisions when browsing through revisions.
1.17ExtensionTypesCalled when generating the extensions credits, use this to change the tables headers.
1.37GetActionNameUse this hook to override the action name depending on request parameters.
1.13GetCacheVaryCookiesGet cookies that should vary cache options.
1.18GetCanonicalURLAllows to modify fully-qualified URLs used for IRC and e-mail notifications.
1.18.0GetDefaultSortkeyAllows to override what the default sortkey is, which is used to order pages in a category.
1.21.0GetDoubleUnderscoreIDsHook for modifying the list of magic words
1.6.0GetFullURLUsed to modify fully-qualified URLs used in redirects/export/offsite data
1.6.0GetInternalURLUsed to modify fully-qualified URLs (useful for squid cache purging)
1.17GetIPModify the ip of the current user (called only once).
1.6.0GetLocalURLUsed to modify local URLs as output into page links
1.19GetLocalURL::ArticleAllows to modify local URLs specifically pointing to article paths without any fancy queries or variants.
1.19GetLocalURL::InternalAllows to modify local URLs to internal pages.
1.35GetMagicVariableIDsUse this hook to modify the list ofmagic variables.
1.35HtmlCacheUpdaterAppendUrlsThis hook is used to declare extra URLs to purge from HTTP caches.
1.35HtmlCacheUpdaterVaryUrlsThis hook is used to add variants of URLs to purge from HTTP caches.
1.20InfoActionWhen building information to display on theaction=info page.
1.13InitializeArticleMaybeRedirectCalled when checking if title is a redirect.
1.18InterwikiLoadPrefix(deprecated in 1.36) This hook is called when resolving whether a given prefix is an interwiki or not.
1.18IRCLineURLWhen constructing the URL to use in an IRC notification.
1.19Language::getMessagesFileNameUse to change the path of a localisation file.
1.18LanguageGetTranslatedLanguageNamesProvide translated language names.
1.22.0LanguageLinksManipulate a page's language links.
1.14.0LinkBegin(removed in 1.36) Used when generating internal and interwiki links inLinker::link()
1.14.0LinkEnd(removed in 1.36) Used when generating internal and interwiki links inLinker::link(), just before the function returns a value.
1.12LinksUpdateAt the beginning ofLinksUpdate::doUpdate() just before the actual update.
1.21LinksUpdateAfterInsertOccurs right after new links have been inserted into the links table.
1.12LinksUpdateCompleteAt the end ofLinksUpdate::doUpdate() when updating has completed.
1.11LinksUpdateConstructedAt the end ofLinksUpdate() is construction.
1.10.1LoadExtensionSchemaUpdatesFired when MediaWiki is updated to allow extensions to register updates for the database schema.
1.24LocalisationCacheRecacheFallbackCalled for each language when merging fallback data into the cache.
1.16LocalisationCacheRecacheCalled when loading the localisation data into cache.
1.23LocalisationChecksBlacklistWhen fetching the blacklist of localisation checks.
1.24LocalisationIgnoredOptionalMessagesargs = array &$ignoredMessageKeys, array &$optionalMessageKeys
1.6.0MagicWordwgVariableIDs(deprecated in 1.35) Tells MediaWiki that one or more magic word IDs should be treated as variables.
1.18MaintenanceRefreshLinksInitBefore executing the refreshLinks.php maintenance script.
1.33MaintenanceUpdateAddParamsAllow extensions to add params to the update.php maintenance script.
1.23MathMLChangedIs called before the MathML property is changed can be used e.g. for compression, normalisation or introduction of custom hyperlinks etc.
1.12.0MediaWikiPerformActionOverrideMediaWiki::performAction()
1.32MediaWikiPHPUnitTest::endTestOccurs when a MediaWiki PHPUnit test has ended.
1.32MediaWikiPHPUnitTest::startTestOccurs when a MediaWiki PHPUnit test has started.
1.27.0MediaWikiServicesCalled when a global MediaWikiServices instance is initialised.
1.23MessageCache::getAllows changing a message key, to customise it before the translation is accessed.
1.41MessageCacheFetchOverridesAllows changing message keys, to customise it before the translation is accessed
1.15MessageCacheReplaceWhen a message page is changed. Useful for updating caches.
1.5.7MessagesPreLoadOccurs when loading a message from the database
1.24MimeMagicGuessFromContentAllows MW extensions guess the MIME by content.
1.24MimeMagicImproveFromExtensionAllows MW extensions to further improve the MIME type detected by considering the file extension.
1.24MimeMagicInitBefore processing the list mapping MIME types to media types and the list mapping MIME types to file extensions. As an extension author, you are encouraged to submit patches to MediaWiki's core to add new MIME types to mime.types.
1.13OpenSearchUrlsCalled when constructing the OpenSearch description XML. Hooks can alter or append to the array of URLs for search & suggestion formats.
1.25OpportunisticLinksUpdateAllows performing updates when a page is re-rendered.
1.20ParserTestGlobalsAllows to define globals for parser tests.
1.6.0ParserTestParserCalled when creating a new instance of Parser for parser tests
1.10ParserTestTables(deprecated in 1.36) Alter the list of tables to duplicate when parser tests are run. Use when page save hooks require the presence of custom tables to ensure that tests continue to run properly.
1.12PrefixSearchBackend(deprecated in 1.27) Override the title prefix search used for OpenSearch and AJAX search suggestions.
1.25PrefixSearchExtractNamespaceCalled if core was not able to extract a namespace from the search string so that extensions can attempt it.
1.10RawPageViewBeforeOutputCalled before displaying a page with action=raw. Returnstrue if display is allowed,false if display is not allowed.
1.30RecentChangesPurgeRowsCalled when oldrecentchanges rows are purged, after deleting those rows but within the same transaction.
1.27RequestHasSameOriginSecurityCalled to determine if the request is somehow flagged to lack same-origin security.
1.8.0RecentChange_saveCalled after a "Recent Change" is committed to the DB
1.16SearchableNamespacesAn option to modify which namespaces are searchable.
1.21SearchAfterNoDirectMatchIf there was no match for the exact result. This runs before lettercase variants are attempted, whereasSearchGetNearMatch runs after.
1.28SearchDataForIndexAllows to provide custom content fields when indexing a document.
1.40SearchDataForIndex2Allows to provide custom content fields when indexing a document.
1.16SearchGetNearMatchBeforePerform exact-title-matches in "go" searches before the normal operations.
1.16SearchGetNearMatchCompleteA chance to modify exact-title-matches in "go" searches.
1.12SearchGetNearMatchAn extra chance for exact-title-matches in "go" searches.
1.28SearchIndexFieldsAdd fields to search index mapping.
1.20SearchResultInitFromTitleSet the revision used when displaying a page in search results.
1.35SearchResultProvideDescriptionCalled when generating search results in order to fill the "description" field in an extension.
1.35SearchResultProvideThumbnailThis hook is called when generating search results in order to fill thethumbnail field in an extension.
1.28SearchResultsAugmentAllows extension to add its code to the list of search result augmentors.
1.25SecondaryDataUpdates(deprecated in 1.32) Allows modification of the list of DataUpdates to perform when page content is modified.
1.24SelfLinkBeginCalled when rendering a self link on a page.
1.23SendWatchlistEmailNotificationCan be used to cancel watchlist email notifications (enotifwatchlist) for an edit.
1.14SetupAfterCacheCalled in Setup.php, after cache objects are set.
1.15SoftwareInfoCalled by Special:Version for returning information about the software.
1.18TestCanonicalRedirectCalled when about to force a redirect to a canonical URL for a title when we have no other parameters on the URL.
1.22.0TitleSquidURLsTo modify/provide alternate URLs to send HTTP PURGE requests.
1.30.0UnitTestsAfterDatabaseSetupCalled right after MediaWiki's test infrastructure has finished creating/duplicating core tables for unit tests.
1.30.0UnitTestsBeforeDatabaseTeardownCalled right before MediaWiki's test infrastructure begins tearing down tables for unit tests.
1.17.0UnitTestsListAdd tests that should be run as part of the unit test suite.
1.24.0UserMailerChangeReturnPathCalled to generate a VERP return address when UserMailer sends an email, with a bounce handling extension.
1.29WatchedItemQueryServiceExtensionsAdd a WatchedItemQueryServiceExtension.
1.19WebRequestPathInfoRouterWhile building the PathRouter to parse the REQUEST_URI.
1.22WebResponseSetCookieUse to modify the cookie being set fromWebResponse::setcookie().
1.20wfShellWikiCmdCalled when generating a shell-escaped command line string to run a cli script.
1.6.0wgQueryPagesRuns for every Special page that extends the QueryPage class (fired when including the file QueryPage.php). It is only useful in maintenance/updateSpecialPages.php and in QueryPage Api.


Alphabetical list of hooks

For a complete list of hooks, use thecategory, which should be kept more up to date.

See also

Setup
Implementation
Extension points
General
Pages
Content
Wiki markup
Moderation
Authentication
Best practices
Tools
Retrieved from "https://www.mediawiki.org/w/index.php?title=Manual:Hooks&oldid=8080565"
Categories:

[8]ページ先頭

©2009-2025 Movatter.jp