Manual:Hooks
From MediaWiki.org
| Tag Extensions | Parser Functions | Hooks | Special Pages | Skins | Magic Words |
MediaWiki provides several hooks that can be used to extend the functionality of the MediaWiki software. Assigning a function (known as an event 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.
Hooks should be assigned at the end of LocalSettings.php or in your own extension file. The easiest way to assign a function to a hook is:
$wgHooks['event'][] = 'function';
which adds an element to the array $wgHooks. You can also create new hooks in your own extension. Hooks created this way should be added to the Extension Hook Registry.
Contents |
[edit] Background
Each hook is represented in the code by a call of function wfRunHooks which is defined in file Hooks.php. The first argument of wfRunHooks is the name of the hook, the second is the array of arguments of the hook. Function wfRunhook finds the tasks to be done from the array $wgHooks. It calls the PHP function call_user_func_array with arguments being the function to be called and its arguments.
See also the hook specification in SVN.
[edit] Writing an event handler
An event handler is a function that is assigned to a hook, which will be run whenever the event represented by that hook occurs. It consists of:
- a function with some optional accompanying data, or
- an object with a method and some optional accompanying data.
Event handlers are registered by adding them to the global $wgHooks array for a given event. Hooks can be added from any point in the execution before the hook is called, but are most commonly added in LocalSettings.php or its included files. All the following are valid ways to define hooks, with the code that will be executed when 'EventName' happens:
| Format | Syntax | Resulting function call. |
|---|---|---|
| Function, no data | $wgHooks['EventName'][] = 'someFunction'; |
someFunction($param1, $param2); |
| Function with data | $wgHooks['EventName'][] = array('someFunction', $someData); |
someFunction($someData, $param1, $param2); |
| Function, no data (weird syntax, but OK) |
$wgHooks['EventName'][] = array('someFunction'); |
someFunction($param1, $param2); |
| Object only | $wgHooks['EventName'][] = $object; |
$object->onEventName($param1, $param2); |
| Object with method | $wgHooks['EventName'][] = array($object, 'someMethod'); |
$object->someMethod($param1, $param2); |
| Object with method and data | $wgHooks['EventName'][] = array($object, 'someMethod', $someData); |
$object->someMethod($someData, $param1, $param2); |
| Object only (weird syntax, but OK) |
$wgHooks['EventName'][] = array($object); |
$object->onEventName($param1, $param2); |
When an event occurs, the function (or object method) will be called with the optional data provided as well as event-specific parameters. Note that when an object is the hook, and there's no specified method, the default method called is 'onEventName'. For different events this would be different: 'onArticleSave', 'onUserLogin', etc.
The extra data is useful if we want to use the same function or object for different purposes. For example:
$wgHooks['ArticleSaveComplete'][] = array('ircNotify', 'TimStarling'); $wgHooks['ArticleSaveComplete'][] = array('ircNotify', 'brion');
This code would result in ircNotify being run twice when an article is saved: once for 'TimStarling', and once for 'brion'.
Event handlers can return one of three possible values:
- true: the hook has operated successfully
- "some string": an error occurred; processing should stop and the error should be shown to the user
- false: the hook has successfully done the work necessary and the calling function should skip
The last result would be for cases where the hook function replaces the main functionality. For example, if you wanted to authenticate users to a custom system (LDAP, another PHP program, whatever), you could do:
$wgHooks['UserLogin'][] = array('ldapLogin', $ldapServer); $ldap['server']="ldaps://ldap.company.com/"; $ldap['port'] = 636; $ldap['base'] = ",ou=Staff,dc=company,dc=com"; function ldapLogin($username, $password) { global $ldap; $auth_user="uid=".$username.$ldap['base']; if($connect=@ldap_connect($ldap['server'],$ldap['port'])){ if($bind=@ldap_bind($connect, $auth_user, $password)){ @ldap_close($connect); return(true); }//if bound to ldap else { echo "Error on ldap_bind"; } }//if connected to ldap else { echo "Error on ldap_connect"; } @ldap_close($connect); return(false); }
Returning false makes less sense for events where the action is complete, and will normally be ignored.
[edit] Available hooks
This page contains a list of hooks that are made available by the MediaWiki software, and is known to be complete to version 1.8.2. There is a lot of detail missing for the more recent hooks in particular, as their purpose/usage has not yet been documented by the developers. If you have any further information on any of these then please add it in the appropriate place.
In the tables, the first column gives the MediaWiki version that the hook was introduced in; use the link in the second column to find out more information about the hook and how to use it.
[edit] Hooks grouped by function
Some of these hooks can be grouped into multiple functions.
| Function | Version | Hook | Description |
|---|---|---|---|
| Article Management | 1.12.0 | AbortMove | Allows to abort moving page from one title to another |
| 1.6.0 | AlternateEdit | Occurs whenever action=edit is called | |
| 1.4.0 | ArticleDelete | Occurs whenever the software receives a request to delete an article | |
| 1.4.0 | ArticleDeleteComplete | Occurs after the delete article request has been processed | |
| 1.8.0 | ArticleFromTitle | Called to determine the class to handle the article rendering, based on title | |
| 1.6.0 | ArticleInsertComplete | Occurs after a new article has been created | |
| 1.4.0 | ArticleProtect | Occurs whenever the software receives a request to protect an article | |
| 1.4.0 | ArticleProtectComplete | Occurs after the protect article request has been processed | |
| 1.4.0 | ArticleSave | Occurs whenever the software receives a request to save an article | |
| 1.4.0 | ArticleSaveComplete | Occurs after the save article request has been processed | |
| 1.4.0 | TitleMoveComplete | Occurs whenever a request to move an article is completed | |
| Page Rendering | 1.6.0 | ArticleAfterFetchContent | |
| 1.6.0 | ArticlePageDataBefore | ||
| 1.6.0 | ArticlePageDataAfter | ||
| 1.5.0 | ParserBeforeStrip | Used to process the raw wiki code before any internal processing is applied. | |
| 1.5.0 | ParserAfterStrip | Used to process raw wiki code after text surrounded by <nowiki> tags have been protected but before any other wiki text has been processed. |
|
| 1.6.0 | ParserBeforeInternalParse | Replaces 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.10.0 | InternalParseBeforeLinks | Used to process the expanded wiki code after <nowiki>, HTML-comments, and templates have been treated. Suitable for syntax extensions that want to customize the treatment of internal link syntax, i.e. [[....]]. |
|
| 1.5.0 | ParserBeforeTidy | Used to process the nearly-rendered html code for the page (but before any html tidying occurs) | |
| 1.5.0 | ParserAfterTidy | Used to add some final processing to the fully-rendered page output | |
| 1.6.0 | ParserClearState | ||
| 1.6.0 | ParserGetVariableValueSwitch | ||
| 1.6.0 | ParserGetVariableValueTs | ||
| 1.6.0 | ParserGetVariableValueVarCache | ||
| 1.6.0 | OutputPageBeforeHTML | Called after the page has been rendered, but before the HTML is displayed. | |
| 1.8.0 | OutputPageParserOutput | ||
| 1.4.3 | CategoryPageView | Called before viewing a categorypage in CategoryPage::view | |
| 1.6.0 | PageRenderingHash | ||
| 1.6.0 | ArticleViewHeader | Called after an articleheader is shown | |
| 1.5.1 | ArticleViewRedirect | ||
| 1.11.0 | EditSectionLinkForOther | Called after creating [edit] link in header in Linker::editSectionLinkForOther but before HTML is displayed. | |
| 1.11.0 | EditSectionLink | Called after creating [edit] link in header in Linker::editSectionLink but before HTML is displayed. | |
| User Interface | 1.5.4 | AutoAuthenticate | Called to authenticate users on external/environmental means |
| 1.4.0 | UserLoginComplete | Occurs after a user has successfully logged in | |
| 1.4.0 | UserLogout | Occurs when the software receives a request to log out | |
| 1.4.0 | UserLogoutComplete | Occurs after a user has successfully logged out | |
| 1.6.0 | userCan | To interrupt/advise the "user can do X to Y article" check | |
| 1.4.0 | WatchArticle | Occurs whenever the software receives a request to watch an article | |
| 1.4.0 | WatchArticleComplete | Occurs after the watch article request has been processed | |
| 1.4.0 | UnwatchArticle | Occurs whenever the software receives a request to unwatch an article | |
| 1.4.0 | UnwatchArticleComplete | Occurs after the unwatch article request has been processed | |
| 1.6.0 | MarkPatrolled | Called before an edit is marked patrolled | |
| 1.6.0 | MarkPatrolledComplete | Called after an edit is marked patrolled | |
| 1.4.0 | EmailUser | Occurs whenever the software receives a request to send an email from one user to another | |
| 1.4.0 | EmailUserComplete | Occurs after an email has been sent from one user to another | |
| 1.6.0 | UploadVerification | Called when a file is uploaded, to allow extra file verification to take place | |
| 1.6.4 | UploadComplete | Called when a file upload has completed. | |
| 1.6.0 | SpecialMovepageAfterMove | Called after a page is moved. | |
| 1.6.0 | SpecialSearchNogomatch | ||
| 1.5.7 | ArticleEditUpdateNewTalk | ||
| 1.5.7 | UserRetrieveNewTalks | ||
| 1.5.7 | UserClearNewTalkNotification | ||
| 1.6.0 | ArticlePurge | ||
| Special pages | 1.6.0 | SpecialPageGetRedirect | |
| 1.13.0 | SpecialListusersDefaultQuery | Called right before the end of UsersPager::getDefaultQuery() | |
| 1.13.0 | SpecialListusersFormatRow | Called right before the end of UsersPager::formatRow() | |
| 1.13.0 | SpecialListusersHeader | Called before closing the <fieldset> in UsersPager::getPageHeader() | |
| 1.13.0 | SpecialListusersHeaderForm | Called before adding the submit button in UsersPager::getPageHeader() | |
| 1.13.0 | SpecialListusersQueryInfo | Called right before the end of UsersPager::getQueryInfo() | |
| 1.6.0 | SpecialPageExecuteBeforeHeader | ||
| 1.6.0 | SpecialPageExecuteBeforePage | ||
| 1.6.0 | SpecialPageExecuteAfterPage | ||
| 1.6.0 | SpecialVersionExtensionTypes | ||
| SpecialPage_initList | Called after the Special Page list is populated | ||
| 1.9.0 | UploadForm:initial | Called just before the upload form is generated | |
| 1.9.0 | UploadForm:BeforeProcessing | Called just before the file data (for example description) are processed, so extensions have a chance to manipulate them. | |
| User Management | 1.5.0 | AddNewAccount | Called after a user account is created |
| 1.5.8 | AbortNewAccount | Can be used to cancel user account creation | |
| 1.4.0 | BlockIp | Occurs whenever the software receives a request to block an IP address or user | |
| 1.4.0 | BlockIpComplete | Occurs after the request to block an IP or user has been processed | |
| 1.6.0 | UserRights | Called after a user's group memberships are changed | |
| 1.6.0 | GetBlockedStatus | ||
| Logging | 1.6.0 | LogPageActionText | |
| 1.5.0 | LogPageLogHeader | ||
| 1.5.0 | LogPageLogName | ||
| 1.5.0 | LogPageValidTypes | ||
| Skinning / Templates | 1.7.0 | BeforePageDisplay | Allows last minute changes to the output page, e.g. adding of CSS or Javascript by extensions. |
| 1.6.0 | MonoBookTemplateToolboxEnd | Called by Monobook skin after toolbox links have been rendered (useful for adding more) | |
| 1.7.0 | PersonalUrls | (SkinTemplate.php) Called after the list of personal URLs (links at the top in Monobook) has been populated. | |
| 1.12.0 | SubPageSubtitle | (Skin.php) Called before the list of subpage links on top of a subpage is generated | |
| 1.5.0 | SkinTemplateContentActions | Called after the default tab list is populated (list is context dependent i.e. "normal" article or "special page"). | |
| 1.6.0 | SkinTemplateTabs | Called after the skin's default tab list is populated. | |
| 1.6.0 | SkinTemplatePreventOtherActiveTabs | Called to enable/disable the inclusion of additional tabs to the skin. | |
| 1.6.0 | SkinTemplateSetupPageCss | ||
| 1.6.0 | SkinTemplateBuildContentActionUrlsAfterSpecialPage | ||
| 1.6.0 | SkinTemplateBuildNavUrlsNav_urlsAfterPermalink | Called after the permalink has been entered in navigation URL array. | |
| 1.6.0 | UserCreateForm | Allows for last minute updates to the UserCreateForm (SpecialUserLogin.php). | |
| 1.6.0 | UserLoginForm | Allows for last minute updates to the UserLoginForm (SpecialUserLogin.php). | |
| API | 1.13.0 | APIEditBeforeSave | Called right before saving an edit submitted through api.php?action=edit |
| Miscellaneous | 1.6.0 | ArticleEditUpdatesDeleteFromRecentchanges | |
| 1.6.0 | EditFilter | ||
| 1.6.0 | EditPage::showEditForm:initial | Used to modify the Edit Form. | |
| 1.6.0 | EditPage::showEditForm:fields | Allows injection of form field into edit form. | |
| 1.8.3 | EditPage::attemptSave | Called before an article is saved, that is before insertNewArticle() is called | |
| 1.12.0 | EditPageBeforeEditButtons | Used to modify the edit buttons on the edit form | |
| 1.6.0 | GetInternalURL | Used to modify fully-qualified URLs (useful for squid cache purging) | |
| 1.6.0 | GetLocalURL | Used to modify local URLs as output into page links | |
| 1.6.0 | GetFullURL | Used to modify fully-qualified URLs used in redirects/export/offsite data | |
| 1.6.0 | LanguageGetMagic | Used for parser function extensions | |
| 1.6.0 | MagicWordMagicWords | ||
| 1.6.0 | MagicWordwgVariableIDs | ||
| 1.5.7 | MessagesPreLoad | ||
| 1.6.0 | ParserTestParser | ||
| 1.5.0 | SpecialContributionsBeforeMainOutput | ||
| 1.4.0 | UnknownAction | Used to add new query-string actions | |
| 1.6.0 | wgQueryPages | ||
| 1.8.0 | DisplayOldSubtitle | ||
| 1.8.0 | LoadAllMessages | ||
| 1.8.0 | RecentChange_save | Called after a "Recent Change" is commited to the DB | |
| 1.8.0 | UserToggles | Called before returning "user toggle names" |
[edit] Alphabetical list of hooks
| Version | Hook | Called From | Description |
|---|---|---|---|
| 1.10.0 | AbortLogin | SpecialUserlogin.php | Allows an extension like a captcha to abort the login process |
| 1.12.0 | AbortMove | Title.php, SpecialMovepage.php | Can be used to cancel page movement |
| 1.5.8 | AbortNewAccount | SpecialUserlogin.php | Can be used to cancel user account creation |
| 1.5.0 | AddNewAccount | SpecialUserlogin.php | Called after a user account is created |
| 1.9.1 | AjaxAddScript | OutputPage.php | Called in output page just before the initialisation |
| 1.6.0 | AlternateEdit | EditPage.php | Occurs whenever action=edit is called |
| 1.13.0 | APIEditBeforeSave | ApiEditPage.php | Called right before saving an edit submitted through api.php?action=edit |
| 1.6.0 | ArticleAfterFetchContent | Article.php | Used to process raw wiki code after most of the other parser processing is complete. |
| 1.4.0 | ArticleDelete | Article.php | Occurs whenever the software receives a request to delete an article |
| 1.4.0 | ArticleDeleteComplete | Article.php | Occurs after the delete article request has been processed |
| 1.5.7 | ArticleEditUpdateNewTalk | Article.php | Allows an extension to prevent user notification when a new message is added to their talk page. |
| 1.6.0 | ArticleEditUpdatesDeleteFromRecentchanges | Article.php | Occurs before saving to the database. If returning false old entries are not deleted from the recentchangeslist. |
| 1.8.0 | ArticleFromTitle | Wiki.php | Called to determine the class to handle the article rendering, based on title. |
| 1.6.0 | ArticleInsertComplete | Article.php | Called after an article is created |
| 1.12.0 | ArticleMergeComplete | SpecialMergeHistory.php | after merging to article using Special:Mergehistory |
| 1.6.0 | ArticlePageDataAfter | Article.php | after loading data of an article from the database |
| 1.6.0 | ArticlePageDataBefore | Article.php | before loading data of an article from the database |
| 1.4.0 | ArticleProtect | Article.php | Occurs whenever the software receives a request to protect an article |
| 1.4.0 | ArticleProtectComplete | Article.php | Occurs after the protect article request has been processed |
| 1.6.0 | ArticlePurge | Article.php | Allows an extension to cancel a purge. |
| 1.13.0 | ArticleRevisionVisiblitySet | SpecialRevisiondelete.php | called when changing visibility of one or more revisions of an article |
| 1.12.0 | ArticleRevisionUndeleted | SpecialUndelete.php | Occurs after an article revision is restored |
| 1.12.0 | ArticleRollbackComplete | Article.php | Occurs after an article rollback is completed |
| 1.4.0 | ArticleSave | Article.php | Occurs whenever the software receives a request to save an article |
| 1.4.0 | ArticleSaveComplete | Article.php | Occurs after the save article request has been processed |
| 1.9.1 | ArticleUndelete | SpecialUndelete.php | When one or more revisions of an article are restored |
| 1.11.0 | ArticleUpdateBeforeRedirect | Article.php |
Occurs after a page is updated (usually on save), before the user is redirected back to the page |
| 1.6.0 | ArticleViewHeader | Article.php | Occurs when header is shown |
| 1.5.1 | ArticleViewRedirect | Article.php | Allows an extension to prevent the display of a "Redirected From" link on a redirect page. |
| 1.13.0 | AuthPluginAutoCreate | SpecialUserlogin.php | Called when creating a local account for an user logged in from an external authentication method |
| 1.9.1 | AuthPluginSetup | Setup.php | Update or replace authentication plugin object ($wgAuth) |
| 1.5.4 | AutoAuthenticate | StubObject.php | Called to authenticate users on external/environmental means. |
| 1.12.0 | AutopromoteCondition | Autopromote.php | check autopromote condition for user. |
| 1.7.0 | BadImage | ImageFunctions.php | Before bad image list is evaluated |
| 1.10.1 | BeforeGalleryFindFile | ImageGallery.php | Allows extensions to specify a specific version of an image to display in a gallery. |
| 1.7.0 | BeforePageDisplay | SkinTemplate.php | Allows last minute changes to the output page, e.g. adding of CSS or Javascript by extensions. |
| 1.10.1 | BeforeParserFetchTemplateAndtitle | Parser.php | Before a template is fetched by Parser |
| 1.10.1 | BeforeParserMakeImageLinkObj | Parser.php | Before an image is rendered by Parser |
| 1.10.1 | BeforeParserrenderImageGallery | Parser.php | Before an image gallery is rendered by Parser |
| 1.12.0 | BeforeWatchlist | SpecialWatchlist.php | Override watchlist display or add extra SQL clauses. |
| 1.4.0 | BlockIp | SpecialBlockip.php | Occurs whenever the software receives a request to block an IP address or user |
| 1.4.0 | BlockIpComplete | SpecialBlockip.php | Occurs after the request to block an IP or user has been processed |
| 1.9.1 | BookInformation | SpecialBooksources.php | Before information output on Special:Booksources |
| 1.13.0 | BrokenLink | Linker.php | Before the HTML is created for a broken (i.e. red) link |
| 1.4.3 | CategoryPageView | CategoryPage.php | Called before viewing a categorypage in CategoryPage::view |
| 1.12.0 | ChangesListInsertArticleLink | ChangesList.php | Override or augment link to article in RC list. |
| 1.11.0 | ContributionsToolLinks | SpecialContributions.php | Change tool links above Special:Contributions |
| 1.9.1 | CustomEditor | Wiki.php | When invoking the page editor. Return true to allow the normal editor to be used, or false
if implementing a custom editor, e.g. for a special namespace, etc. |
| 1.7.0 | DiffViewHeader | DifferenceEngine.php | Called before diff display |
| 1.8.0 | DisplayOldSubtitle | Article.php | Allows extensions to modify the displaying of links to other revisions when browsing through revisions. |
| 1.6.0 | EditFilter | EditPage.php | Perform checks on an edit |
| 1.12.0 | EditFilterMerged | EditPage.php | Perform checks on an edit |
| 1.7.0 | EditFormPreloadText | EditPage.php | Called when edit page for a new article is shown. This lets you fill the text-box of a new page with initial wikitext. |
| 1.8.3 | EditPage::attemptSave | EditPage.php | Called before an article is saved, that is before insertNewArticle() is called |
| 1.6.0 | EditPage::showEditForm:fields | EditPage.php | Allows injection of form field into edit form. |
| 1.6.0 | EditPage::showEditForm:initial | EditPage.php | before showing the edit form |
| 1.13.0 | EditPageBeforeConflictDiff | EditPage.php | Allows modifying the EditPage object and output when there's an edit conflict. |
| 1.12.0 | EditPageBeforeEditButtons | EditPage.php | Used to modify the edit buttons on the edit form |
| 1.11.0 | EditSectionLink | EditPage.php | Override the return value of Linker::editSectionLink() |
| 1.11.0 | EditSectionLinkForOther | EditPage.php | Override the return value of Linker::editSectionLink() |
| 1.7.0 | EmailConfirmed | User.php | When checking that the user's email address is "confirmed" |
| 1.4.0 | EmailUser | SpecialEmailuser.php | Occurs whenever the software receives a request to send an email from one user to another |
| 1.4.0 | EmailUserComplete | SpecialEmailuser.php | Occurs after an email has been sent from one user to another |
| 1.7.0 | FetchChangesList | ChangesList.php | Allows extension to modify a recent changes list for a user. |
| 1.13.0 | FileDeleteComplete | FileDeleteForm.php | When a file is deleted |
| 1.11.0 | FileUpload | filerepo/LocalFile.php | When a file upload occurs |
| 1.13.0 | FileUndeleteComplete | SpecialUndelete.php | When a file is undeleted |
| 1.6.0 | GetBlockedStatus | User.php | Fired after the user's getBlockStatus is set. |
| 1.13.0 | GetCacheVaryCookies | OutputPage.php | get cookies that should vary cache options |
| 1.6.0 | GetFullURL | Title.php | Used to modify fully-qualified URLs used in redirects/export/offsite data |
| 1.6.0 | GetInternalURL | Title.php | Used to modify fully-qualified URLs (useful for squid cache purging) |
| 1.12.0 | GetLinkColours | Parser.php | modify the CSS class of an array of page links |
| 1.6.0 | GetLocalURL | Title.php | Used to modify local URLs as output into page links |
| 1.12.0 | getUserPermissionsErrors | Title.php | Add a permissions error when permissions errors are checked for. |
| 1.12.0 | getUserPermissionsErrorsExpensive | Title.php | Absolutely the same, but is called only if expensive checks are enabled. |
| 1.13.0 | ImageBeforeProduceHTML | Linker.php | Called before producing the HTML created by a wiki image insertion. |
| 1.11.0 | ImageOpenShowImageInlineBefore | ImagePage.php | Call potential extension just before showing the image on an image page. |
| 1.11.0 | InitPreferencesForm | SpecialPreferences.php | Called at the end of PreferencesForm's constructor |
| 1.10.0 | InternalParseBeforeLinks | Parser.php | Used to process the expanded wiki code after <nowiki>, HTML-comments, and templates have been treated. Suitable for syntax extensions that want to support templates and comments. |
| 1.10.0 | IsFileCacheable | Article.php | Allow an extension to disable file caching on pages. |
| 1.9.0 | IsTrustedProxy | ProxyTools.php | Allows an extension to set an IP as trusted or not. |
| 1.12.0 | isValidEmailAddr | User.php | Override the result of User::isValidEmailAddr() |
| 1.11.0 | isValidPassword | User.php | Override the result of User::isValidPassword() |
| 1.6.0 | LanguageGetMagic | languages/Language.php | Use this to define synonyms of magic words depending of the language |
| 1.9.0 | LanguageGetSpecialPageAliases | languages/Language.php | Use to define aliases of special pages names depending of the language |
| 1.12.0 | LinksUpdate | LinksUpdate.php | At the beginning of LinksUpdate::doUpdate() just before the actual update. |
| 1.12.0 | LinksUpdateComplete | LinksUpdate.php | At the end of LinksUpdate::doUpdate() when updating has completed. |
| 1.11.0 | LinksUpdateConstructed | LinksUpdate.php | At the end of LinksUpdate() is construction. |
| 1.8.0 | LoadAllMessages | MessageCache.php | called by MessageCache::loadAllMessages() to load extensions messages |
| 1.10.1 | LoadExtensionSchemaUpdates | maintenance/updaters.inc | Fired when MediaWiki is updated to allow extensions to update the database. |
| 1.10.0 | LoginAuthenticateAudit | SpecialUserLogin.php | A login attempt for a valid user account either succeeded or failed. No return data is accepted; this hook is for auditing only. |
| 1.12.0 | LogLine | SpecialLog.php | Processes a single log entry on Special:Log |
| 1.6.0 | LogPageActionText | Setup.php | Strings used by wfMsg as a header. DEPRECATED: Use $wgLogActions |
| 1.5.0 | LogPageLogHeader | Setup.php | Strings used by wfMsg as a header. DEPRECATED: Use $wgLogHeaders |
| 1.5.0 | LogPageLogName | Setup.php | Name of the logging page(s). DEPRECATED: Use $wgLogNames |
| 1.5.0 | LogPageValidTypes | Setup.php | Action being logged. DEPRECATED: Use $wgLogTypes |
| 1.6.0 | MagicWordMagicWords | MagicWord.php | Allows extensions to define new magic words. DEPRECATED: Use LanguageGetMagic instead. |
| 1.6.0 | MagicWordwgVariableIDs | MagicWord.php | Allows extensions to add Magic Word IDs. DEPRECATED: Use LanguageGetMagic instead. |
| 1.6.0 | MarkPatrolled | Article.php | Called before an edit is marked patrolled |
| 1.6.0 | MarkPatrolledComplete | Article.php | Called after an edit is marked patrolled |
| 1.7.0 | MathAfterTexvc | Math.php | After texvc is executed when rendering mathematics |
| 1.12.0 | MediaWikiPerformAction | Wiki.php | Override MediaWiki::performAction(). |
| 1.5.7 | MessagesPreLoad | MessageCache.php | Occurs when loading a message from the database |
| 1.6.0 | MonoBookTemplateToolboxEnd | skins/Monobook.php | Called by Monobook skin after toolbox links have been rendered (useful for adding more) |
| 1.6.0 | OutputPageBeforeHTML | OutputPage.php | Called after the page has been rendered, but before the HTML is displayed. |
| 1.8.0 | OutputPageParserOutput | OutputPage.php | after adding a parserOutput to $wgOut |
| 1.10.0 | PageHistoryBeforeList | PageHistory.php | When a history page list is about to be constructed. |
| 1.10.0 | PageHistoryLineEnding | PageHistory.php | Right before the end >li> is added to a history line |
| 1.6.0 | PageRenderingHash | User.php | Alter the parser cache option hash key |
| 1.5.0 | ParserAfterStrip | Parser.php | Same as ParserBeforeStrip |
| 1.5.0 | ParserAfterTidy | Parser.php | Used to add some final processing to the fully-rendered page output |
| 1.6.0 | ParserBeforeInternalParse | Parser.php | called at the beginning of Parser::internalParse() |
| 1.5.0 | ParserBeforeStrip | Parser.php | Used to process the raw wiki code before any internal processing is applied |
| 1.5.0 | ParserBeforeTidy | Parser.php | Used to process the nearly-rendered html code for the page (but before any html tidying occurs) |
| 1.6.0 | ParserClearState | Parser.php | called at the end of Parser::clearState() |
| 1.12.0 | ParserFirstCallInit | Parser.php | called when the parser initialises for the first time |
| 1.6.0 | ParserGetVariableValueSwitch | Parser.php | called when the parser need the value of a custom magic word |
| 1.6.0 | ParserGetVariableValueTs | Parser.php | use this to change the value of the time for the {{LOCAL...}} magic word |
| 1.6.0 | ParserGetVariableValueVarCache | Parser.php | use this to change the value of the variable cache or return false to not use it |
| 1.12.0 | ParserLimitReport | Parser.php | called at the end of Parser::parse() when the parser will include comments about size of the text parsed |
| 1.12.0 | ParserMakeImageParams | Parser.php | called at the end of Parser::makeImage(). Alter the parameters used to generate an image. |
| 1.6.0 | ParserTestParser | maintenance/Parser.inc | called when creating a new instance of Parser in maintenance/parserTests.inc |
| 1.10.0 | ParserTestTables | maintenance/parserTests.inc | 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.6.0 | PersonalUrls | SkinTemplate.php | Alter the user-specific navigation links (e.g. "my page, my talk page, my contributions" etc). |
| 1.9.0 | PingLimiter | User.php | Allows extensions to override the results of User::pingLimiter() |
| 1.9.0 | PreferencesUserInformationPanel | SpecialPreferences.php | Add HTML bits to user information list in preferences form |
| 1.12.0 | PrefixSearchBackend | PrefixSearch.php | Override the title prefix search used for OpenSearch and AJAX search suggestions. |
| 1.11.0 | PrefsEmailAudit | SpecialPreferences.php | called when user changes his email address |
| 1.11.0 | PrefsPasswordAudit | SpecialPreferences.php | called when user changes his password |
| 1.10.0 | RawPageViewBeforeOutput | RawPage.php | Right before the text is blown out in action=raw |
| 1.8.0 | RecentChange_save | RecentChange.php | Called after a "Recent Change" is commited to the DB |
| 1.11.0 | RenderPreferencesForm | SpecialPreferences.php | Called at the end of PreferencesForm::mainPrefsForm |
| 1.11.0 | ResetPreferences | SpecialPreferences.php | Called at the end of PreferencesForm::resetPrefs |
| 1.11.0 | RevisionInsertComplete | Revision.php | Called after a revision is inserted into the DB |
| 1.11.0 | SavePreferences | SpecialPreferences.php | Called at the end of PreferencesForm::savePreferences; returning false prevents the preferences from being saved. |
| 1.12.0 | SearchGetNearMatch | SearchEngine.php | An extra chance for exact-title-matches in "go" searches. |
| 1.10.0 | SearchUpdate | SearchUpdate.php | Prior to search update completion |
| 1.11.0 | ShowRawCssJs | Article.php | Customise the output of raw CSS and JavaScript in page views |
| 1.7.0 | SiteNoticeAfter | GlobalFunctions.php | After site notice is determined |
| 1.7.0 | SiteNoticeBefore | GlobalFunctions.php | Before site notice is determined |
| 1.11.0 | SkinAfterBottomScripts | Skin.php | At the end of Skin::bottomScripts() |
| 1.12.0 | SubPageSubtitle | Skin.php | Called before the list of subpage links on top of a subpage is generated |
| 1.6.0 | SkinTemplateBuildContentActionUrlsAfterSpecialPage | SkinTemplate.php | after the single tab when showing a special page |
| 1.6.0 | SkinTemplateBuildNavUrlsNav_urlsAfterPermalink | SkinTemplate.php | after creating the "permanent link" tab |
| 1.5.0 | SkinTemplateContentActions | SkinTemplate.php | Alter the "content action" links in SkinTemplates |
| 1.10.0 | SkinTemplateOutputPageBeforeExec | SkinTemplate.php | Before SkinTemplate::outputPage() starts page output |
| 1.6.0 | SkinTemplatePreventOtherActiveTabs | SkinTemplate.php and skins/disabled/MonoBookCBT.php | use this to prevent showing active tabs |
| 1.6.0 | SkinTemplateSetupPageCss | SkinTemplate.php and skins/disabled/MonoBookCBT.php | use this to provide per-page CSS |
| 1.12.0 | SkinTemplateTabAction | SkinTemplate.php | Override SkinTemplate::tabAction(). |
| 1.6.0 | SkinTemplateTabs | SkinTemplate.php | called when finished to build the actions tabs |
| 1.13.0 | SkinTemplateToolboxEnd | skins/Monobook.php, skins/Modern.php | Called by SkinTemplate skins after toolbox links have been rendered (useful for adding more) |
| 1.5.0 | SpecialContributionsBeforeMainOutput | SpecialContributions.php | Before the form on Special:Contributions |
| 1.13.0 | SpecialListusersDefaultQuery | SpecialListusers.php | Called right before the end of UsersPager::getDefaultQuery() |
| 1.13.0 | SpecialListusersFormatRow | SpecialListusers.php | Called right before the end of UsersPager::formatRow() |
| 1.13.0 | SpecialListusersHeader | SpecialListusers.php | Called before closing the <fieldset> in UsersPager::getPageHeader() |
| 1.13.0 | SpecialListusersHeaderForm | SpecialListusers.php | Called before adding the submit button in UsersPager::getPageHeader() |
| 1.13.0 | SpecialListusersQueryInfo | SpecialListusers.php | Called right before the end of UsersPager::getQueryInfo() |
| 1.6.0 | SpecialMovepageAfterMove | SpecialMovepage.php | Called after a page is moved. |
| 1.7.0 | SpecialPage_initList | SpecialPage.php | Called when the list of Special Pages is populated. Hook gets a chance to change the list to hide/show pages |
| 1.6.0 | SpecialPageExecuteAfterPage | SpecialPage.php | called after executing a special page |
| 1.6.0 | SpecialPageExecuteBeforeHeader | SpecialPage.php | called before setting the header text of the special page |
| 1.6.0 | SpecialPageExecuteBeforePage | SpecialPage.php | called after setting the special page header text but before the main execution |
| 1.6.0 | SpecialSearchNogomatch | SpecialSearch.php | called when user clicked the "Go" button but the target doesn't exist |
| 1.13.0 | SpecialSearchNoResults | SpecialSearch.php | called before search result display when there are no matches |
| 1.13.0 | SpecialSearchResults | SpecialSearch.php | called before search result display when there are matches |
| 1.6.0 | SpecialVersionExtensionTypes | SpecialVersion.php | called when generating the extensions credits, use this to change the tables headers |
| 1.4.0 | TitleMoveComplete | Title.php | Occurs whenever a request to move an article is completed |
| 1.9.0 | UndeleteShowRevision | SpecialUndelete.php | called when showing a revision in Special:Undelete |
| 1.4.0 | UnknownAction | Wiki.php | Used to add new query-string actions |
| 1.4.0 | UnwatchArticle | Article.php | Occurs whenever the software receives a request to unwatch an article |
| 1.4.0 | UnwatchArticleComplete | Article.php | Occurs after the unwatch article request has been processed |
| 1.6.4 | UploadComplete | SpecialUpload.php | Called when a file upload has completed. |
| 1.9.0 | UploadForm:BeforeProcessing | SpecialUpload.php | Called just before the file data (for example description) are processed, so extensions have a chance to manipulate them. |
| 1.9.0 | UploadForm:initial | SpecialUpload.php | Called just before the upload form is generated |
| 1.6.0 | UploadVerification | SpecialUpload.php | Called when a file is uploaded, to allow extra file verification to take place |
| 1.13.0 | UserArrayFromResult | UserArray.php | called when creating an UserArray object from a database result |
| 1.6.0 | userCan | Title.php | To interrupt/advise the "user can do X to Y article" check |
| 1.12.0 | UserCanSendEmail | User.php | To override User::canSendEmail() permission check |
| 1.5.7 | UserClearNewTalkNotification | User.php | called when clearing the "You have new messages!" message |
| 1.6.0 | UserCreateForm | SpecialUserlogin.php | Change to manipulate the login form |
| 1.11.0 | UserEffectiveGroups | User.php | Called in User::getEffectiveGroups() |
| 1.13.0 | UserGetAllRights | User.php | After calculating a list of all available rights |
| 1.13.0 | UserGetEmail | User.php | Called when getting an user email address |
| 1.13.0 | UserGetEmailAuthenticationTimestamp | User.php | Called when getting the timestamp of email authentification |
| 1.11.0 | UserGetImplicitGroups | User.php | Called in User::getImplicitGroups() |
| 1.11.0 | UserGetRights | User.php | Called in User::getRights() |
| 1.4.0 | UserLoginComplete | SpecialUserlogin.php | Occurs after a user has successfully logged in |
| 1.6.0 | UserLoginForm | SpecialUserlogin.php | Change to manipulate the login form |
| 1.4.0 | UserLogout | SpecialUserlogin.php | Occurs when the software receives a request to log out |
| 1.4.0 | UserLogoutComplete | SpecialUserlogin.php | Occurs after a user has successfully logged out |
| 1.5.7 | UserRetrieveNewTalks | User.php | called when retrieving "You have new messages!" message(s) |
| 1.6.0 | UserRights | SpecialUserrights.php | Called after a user's group memberships are changed |
| 1.13.0 | UserSaveSettings | User.php | Called when saving user settings |
| 1.13.0 | UserSetEmail | User.php | Called when changing user email address |
| 1.13.0 | UserSetEmailAuthenticationTimestamp | User.php | Called when setting the timestamp of email authentification |
| 1.8.0 | UserToggles | User.php | Called before returning "user toggle names" |
| 1.4.0 | WatchArticle | Article.php | Occurs whenever the software receives a request to watch an article |
| 1.4.0 | WatchArticleComplete | Article.php | Occurs after the watch article request has been processed |
| 1.6.0 | wgQueryPages | QueryPage.php | called when initialising $wgQueryPages |
[edit] Hooks grouped by version
To see hooks grouped by version go to the table above and click the arrow symbol in the version table header.

