Merge "Add a function that returns a list of categories the page is a member of"
[lhc/web/wiklou.git] / docs / hooks.txt
1 hooks.txt
2
3 This document describes how event hooks work in MediaWiki; how to add hooks for
4 an event; and how to run hooks for an event.
5
6 ==Glossary==
7
8 event
9 Something that happens with the wiki. For example: a user logs in. A wiki
10 page is saved. A wiki page is deleted. Often there are two events
11 associated with a single action: one before the code is run to make the
12 event happen, and one after. Each event has a name, preferably in
13 CamelCase. For example, 'UserLogin', 'ArticleSave', 'ArticleSaveComplete',
14 'ArticleDelete'.
15
16 hook
17 A clump of code and data that should be run when an event happens. This can
18 be either a function and a chunk of data, or an object and a method.
19
20 hook function
21 The function part of a hook.
22
23 ==Rationale==
24
25 Hooks allow us to decouple optionally-run code from code that is run for
26 everyone. It allows MediaWiki hackers, third-party developers and local
27 administrators to define code that will be run at certain points in the mainline
28 code, and to modify the data run by that mainline code. Hooks can keep mainline
29 code simple, and make it easier to write extensions. Hooks are a principled
30 alternative to local patches.
31
32 Consider, for example, two options in MediaWiki. One reverses the order of a
33 title before displaying the article; the other converts the title to all
34 uppercase letters. Currently, in MediaWiki code, we would handle this as follows
35 (note: not real code, here):
36
37 function showAnArticle($article) {
38 global $wgReverseTitle, $wgCapitalizeTitle;
39
40 if ($wgReverseTitle) {
41 wfReverseTitle($article);
42 }
43
44 if ($wgCapitalizeTitle) {
45 wfCapitalizeTitle($article);
46 }
47
48 # code to actually show the article goes here
49 }
50
51 An extension writer, or a local admin, will often add custom code to the
52 function -- with or without a global variable. For example, someone wanting
53 email notification when an article is shown may add:
54
55 function showAnArticle($article) {
56 global $wgReverseTitle, $wgCapitalizeTitle, $wgNotifyArticle;
57
58 if ($wgReverseTitle) {
59 wfReverseTitle($article);
60 }
61
62 if ($wgCapitalizeTitle) {
63 wfCapitalizeTitle($article);
64 }
65
66 # code to actually show the article goes here
67
68 if ($wgNotifyArticle) {
69 wfNotifyArticleShow($article));
70 }
71 }
72
73 Using a hook-running strategy, we can avoid having all this option-specific
74 stuff in our mainline code. Using hooks, the function becomes:
75
76 function showAnArticle($article) {
77
78 if (wfRunHooks('ArticleShow', array(&$article))) {
79
80 # code to actually show the article goes here
81
82 wfRunHooks('ArticleShowComplete', array(&$article));
83 }
84 }
85
86 We've cleaned up the code here by removing clumps of weird, infrequently used
87 code and moving them off somewhere else. It's much easier for someone working
88 with this code to see what's _really_ going on, and make changes or fix bugs.
89
90 In addition, we can take all the code that deals with the little-used
91 title-reversing options (say) and put it in one place. Instead of having little
92 title-reversing if-blocks spread all over the codebase in showAnArticle,
93 deleteAnArticle, exportArticle, etc., we can concentrate it all in an extension
94 file:
95
96 function reverseArticleTitle($article) {
97 # ...
98 }
99
100 function reverseForExport($article) {
101 # ...
102 }
103
104 The setup function for the extension just has to add its hook functions to the
105 appropriate events:
106
107 setupTitleReversingExtension() {
108 global $wgHooks;
109
110 $wgHooks['ArticleShow'][] = 'reverseArticleTitle';
111 $wgHooks['ArticleDelete'][] = 'reverseArticleTitle';
112 $wgHooks['ArticleExport'][] = 'reverseForExport';
113 }
114
115 Having all this code related to the title-reversion option in one place means
116 that it's easier to read and understand; you don't have to do a grep-find to see
117 where the $wgReverseTitle variable is used, say.
118
119 If the code is well enough isolated, it can even be excluded when not used --
120 making for some slight savings in memory and load-up performance at runtime.
121 Admins who want to have all the reversed titles can add:
122
123 require_once 'extensions/ReverseTitle.php';
124
125 ...to their LocalSettings.php file; those of us who don't want or need it can
126 just leave it out.
127
128 The extensions don't even have to be shipped with MediaWiki; they could be
129 provided by a third-party developer or written by the admin him/herself.
130
131 ==Writing hooks==
132
133 A hook is a chunk of code run at some particular event. It consists of:
134
135 * a function with some optional accompanying data, or
136 * an object with a method and some optional accompanying data.
137
138 Hooks are registered by adding them to the global $wgHooks array for a given
139 event. All the following are valid ways to define hooks:
140
141 $wgHooks['EventName'][] = 'someFunction'; # function, no data
142 $wgHooks['EventName'][] = array('someFunction', $someData);
143 $wgHooks['EventName'][] = array('someFunction'); # weird, but OK
144
145 $wgHooks['EventName'][] = $object; # object only
146 $wgHooks['EventName'][] = array($object, 'someMethod');
147 $wgHooks['EventName'][] = array($object, 'someMethod', $someData);
148 $wgHooks['EventName'][] = array($object); # weird but OK
149
150 When an event occurs, the function (or object method) will be called with the
151 optional data provided as well as event-specific parameters. The above examples
152 would result in the following code being executed when 'EventName' happened:
153
154 # function, no data
155 someFunction($param1, $param2)
156 # function with data
157 someFunction($someData, $param1, $param2)
158
159 # object only
160 $object->onEventName($param1, $param2)
161 # object with method
162 $object->someMethod($param1, $param2)
163 # object with method and data
164 $object->someMethod($someData, $param1, $param2)
165
166 Note that when an object is the hook, and there's no specified method, the
167 default method called is 'onEventName'. For different events this would be
168 different: 'onArticleSave', 'onUserLogin', etc.
169
170 The extra data is useful if we want to use the same function or object for
171 different purposes. For example:
172
173 $wgHooks['ArticleSaveComplete'][] = array('ircNotify', 'TimStarling');
174 $wgHooks['ArticleSaveComplete'][] = array('ircNotify', 'brion');
175
176 This code would result in ircNotify being run twice when an article is saved:
177 once for 'TimStarling', and once for 'brion'.
178
179 Hooks can return three possible values:
180
181 * true: the hook has operated successfully
182 * "some string": an error occurred; processing should stop and the error
183 should be shown to the user
184 * false: the hook has successfully done the work necessary and the calling
185 function should skip
186
187 The last result would be for cases where the hook function replaces the main
188 functionality. For example, if you wanted to authenticate users to a custom
189 system (LDAP, another PHP program, whatever), you could do:
190
191 $wgHooks['UserLogin'][] = array('ldapLogin', $ldapServer);
192
193 function ldapLogin($username, $password) {
194 # log user into LDAP
195 return false;
196 }
197
198 Returning false makes less sense for events where the action is complete, and
199 will normally be ignored.
200
201 Note that none of the examples made use of create_function() as a way to
202 attach a function to a hook. This is known to cause problems (notably with
203 Special:Version), and should be avoided when at all possible.
204
205 ==Using hooks==
206
207 A calling function or method uses the wfRunHooks() function to run the hooks
208 related to a particular event, like so:
209
210 class Article {
211 # ...
212 function protect() {
213 global $wgUser;
214 if (wfRunHooks('ArticleProtect', array(&$this, &$wgUser))) {
215 # protect the article
216 wfRunHooks('ArticleProtectComplete', array(&$this, &$wgUser));
217 }
218 }
219 }
220
221 wfRunHooks() returns true if the calling function should continue processing
222 (the hooks ran OK, or there are no hooks to run), or false if it shouldn't (an
223 error occurred, or one of the hooks handled the action already). Checking the
224 return value matters more for "before" hooks than for "complete" hooks.
225
226 Note that hook parameters are passed in an array; this is a necessary
227 inconvenience to make it possible to pass reference values (that can be changed)
228 into the hook code. Also note that earlier versions of wfRunHooks took a
229 variable number of arguments; the array() calling protocol came about after
230 MediaWiki 1.4rc1.
231
232 ==Events and parameters==
233
234 This is a list of known events and parameters; please add to it if you're going
235 to add events to the MediaWiki code.
236
237 'AbortAutoAccount': Return false to cancel automated local account creation,
238 where normally authentication against an external auth plugin would be creating
239 a local account.
240 $user: the User object about to be created (read-only, incomplete)
241 &$abortMsg: out parameter: name of error message to be displayed to user
242
243 'AbortAutoblock': Return false to cancel an autoblock.
244 $autoblockip: The IP going to be autoblocked.
245 $block: The block from which the autoblock is coming.
246
247 'AbortDiffCache': Can be used to cancel the caching of a diff.
248 &$diffEngine: DifferenceEngine object
249
250 'AbortEmailNotification': Can be used to cancel email notifications for an edit.
251 $editor: The User who made the change.
252 $title: The Title of the page that was edited.
253
254 'AbortLogin': Return false to cancel account login.
255 $user: the User object being authenticated against
256 $password: the password being submitted, not yet checked for validity
257 &$retval: a LoginForm class constant to return from authenticateUserData();
258 default is LoginForm::ABORTED. Note that the client may be using
259 a machine API rather than the HTML user interface.
260 &$msg: the message identifier for abort reason (new in 1.18, not available before 1.18)
261
262 'AbortMove': Allows to abort moving an article (title).
263 $old: old title
264 $nt: new title
265 $user: user who is doing the move
266 $err: error message
267 $reason: the reason for the move (added in 1.13)
268
269 'AbortNewAccount': Return false to cancel explicit account creation.
270 $user: the User object about to be created (read-only, incomplete)
271 &$msg: out parameter: HTML to display on abort
272
273 'AbortTalkPageEmailNotification': Return false to cancel talk page email notification
274 $targetUser: the user whom to send talk page email notification
275 $title: the page title
276
277 'AbortChangePassword': Return false to cancel password change.
278 $user: the User object to which the password change is occuring
279 $mOldpass: the old password provided by the user
280 $newpass: the new password provided by the user
281 &$abortMsg: the message identifier for abort reason
282
283 'ActionBeforeFormDisplay': Before executing the HTMLForm object.
284 $name: name of the action
285 &$form: HTMLForm object
286 $article: Article object
287
288 'ActionModifyFormFields': Before creating an HTMLForm object for a page action;
289 Allows to change the fields on the form that will be generated.
290 $name: name of the action
291 &$fields: HTMLForm descriptor array
292 $article: Article object
293
294 'AddNewAccount': After a user account is created.
295 $user: the User object that was created. (Parameter added in 1.7)
296 $byEmail: true when account was created "by email" (added in 1.12)
297
298 'AfterFinalPageOutput': At the end of OutputPage::output() but before final
299 ob_end_flush() which will send the buffered output to the client. This allows
300 for last-minute modification of the output within the buffer by using
301 ob_get_clean().
302 &$output: OutputPage object
303
304 'AfterImportPage': When a page import is completed.
305 $title: Title under which the revisions were imported
306 $origTitle: Title provided by the XML file
307 $revCount: Number of revisions in the XML file
308 $sRevCount: Number of successfully imported revisions
309 $pageInfo: associative array of page information
310
311 'AfterFinalPageOutput': Nearly at the end of OutputPage::output() but
312 before OutputPage::sendCacheControl() and final ob_end_flush() which
313 will send the buffered output to the client. This allows for last-minute
314 modification of the output within the buffer by using ob_get_clean().
315 $output: The OutputPage object where output() was called
316
317 'AjaxAddScript': Called in output page just before the initialisation
318 of the javascript ajax engine. The hook is only called when ajax
319 is enabled ( $wgUseAjax = true; ).
320 &$output: OutputPage object
321
322 'AlternateEdit': Before checking if a user can edit a page and before showing
323 the edit form ( EditPage::edit() ). This is triggered on &action=edit.
324 $editPage: the EditPage object
325
326 'AlternateEditPreview': Before generating the preview of the page when editing
327 ( EditPage::getPreviewText() ).
328 $editPage: the EditPage object
329 &$content: the Content object for the text field from the edit page
330 &$previewHTML: Text to be placed into the page for the preview
331 &$parserOutput: the ParserOutput object for the preview
332 return false and set $previewHTML and $parserOutput to output custom page
333 preview HTML.
334
335 'AlternateUserMailer': Called before mail is sent so that mail could be logged
336 (or something else) instead of using PEAR or PHP's mail(). Return false to skip
337 the regular method of sending mail. Return a string to return a php-mail-error
338 message containing the error. Returning true will continue with sending email
339 in the regular way.
340 $headers: Associative array of headers for the email
341 $to: MailAddress object or array
342 $from: From address
343 $subject: Subject of the email
344 $body: Body of the message
345
346 'APIAfterExecute': After calling the execute() method of an API module. Use
347 this to extend core API modules.
348 &$module: Module object
349
350 'ApiCheckCanExecute': Called during ApiMain::checkCanExecute. Use to further
351 authenticate and authorize API clients before executing the module. Return
352 false and set a message to cancel the request.
353 $module: Module object
354 $user: Current user
355 &$message: API usage message to die with, as a message key or array
356 as accepted by ApiBase::dieUsageMsg.
357
358 'APIEditBeforeSave': Before saving a page with api.php?action=edit, after
359 processing request parameters. Return false to let the request fail, returning
360 an error message or an <edit result="Failure"> tag if $resultArr was filled.
361 $editPage : the EditPage object
362 $text : the new text of the article (has yet to be saved)
363 &$resultArr : data in this array will be added to the API result
364
365 'APIGetAllowedParams': Use this hook to modify a module's parameters.
366 &$module: ApiBase Module object
367 &$params: Array of parameters
368 $flags: int zero or OR-ed flags like ApiBase::GET_VALUES_FOR_HELP
369
370 'APIGetDescription': Use this hook to modify a module's description.
371 &$module: ApiBase Module object
372 &$desc: Array of descriptions
373
374 'APIGetParamDescription': Use this hook to modify a module's parameter
375 descriptions.
376 &$module: ApiBase Module object
377 &$desc: Array of parameter descriptions
378
379 'APIGetResultProperties': Use this hook to modify the properties in a module's
380 result.
381 &$module: ApiBase Module object
382 &$properties: Array of properties
383
384 'APIGetPossibleErrors': Use this hook to modify the module's list of possible
385 errors.
386 $module: ApiBase Module object
387 &$possibleErrors: Array of possible errors
388
389 'APIQueryAfterExecute': After calling the execute() method of an
390 action=query submodule. Use this to extend core API modules.
391 &$module: Module object
392
393 'APIQueryGeneratorAfterExecute': After calling the executeGenerator() method of
394 an action=query submodule. Use this to extend core API modules.
395 &$module: Module object
396 &$resultPageSet: ApiPageSet object
397
398 'APIQueryInfoTokens': Use this hook to add custom tokens to prop=info. Every
399 token has an action, which will be used in the intoken parameter and in the
400 output (actiontoken="..."), and a callback function which should return the
401 token, or false if the user isn't allowed to obtain it. The prototype of the
402 callback function is func($pageid, $title), where $pageid is the page ID of the
403 page the token is requested for and $title is the associated Title object. In
404 the hook, just add your callback to the $tokenFunctions array and return true
405 (returning false makes no sense).
406 $tokenFunctions: array(action => callback)
407
408 'APIQueryRevisionsTokens': Use this hook to add custom tokens to prop=revisions.
409 Every token has an action, which will be used in the rvtoken parameter and in
410 the output (actiontoken="..."), and a callback function which should return the
411 token, or false if the user isn't allowed to obtain it. The prototype of the
412 callback function is func($pageid, $title, $rev), where $pageid is the page ID
413 of the page associated to the revision the token is requested for, $title the
414 associated Title object and $rev the associated Revision object. In the hook,
415 just add your callback to the $tokenFunctions array and return true (returning
416 false makes no sense).
417 $tokenFunctions: array(action => callback)
418
419 'APIQueryRecentChangesTokens': Use this hook to add custom tokens to
420 list=recentchanges. Every token has an action, which will be used in the rctoken
421 parameter and in the output (actiontoken="..."), and a callback function which
422 should return the token, or false if the user isn't allowed to obtain it. The
423 prototype of the callback function is func($pageid, $title, $rc), where $pageid
424 is the page ID of the page associated to the revision the token is requested
425 for, $title the associated Title object and $rc the associated RecentChange
426 object. In the hook, just add your callback to the $tokenFunctions array and
427 return true (returning false makes no sense).
428 $tokenFunctions: array(action => callback)
429
430 'APIQuerySiteInfoGeneralInfo': Use this hook to add extra information to the
431 sites general information.
432 $module: the current ApiQuerySiteInfo module
433 &$results: array of results, add things here
434
435 'APIQueryUsersTokens': Use this hook to add custom token to list=users. Every
436 token has an action, which will be used in the ustoken parameter and in the
437 output (actiontoken="..."), and a callback function which should return the
438 token, or false if the user isn't allowed to obtain it. The prototype of the
439 callback function is func($user) where $user is the User object. In the hook,
440 just add your callback to the $tokenFunctions array and return true (returning
441 false makes no sense).
442 $tokenFunctions: array(action => callback)
443
444 'ApiMain::onException': Called by ApiMain::executeActionWithErrorHandling() when
445 an exception is thrown during API action execution.
446 $apiMain: Calling ApiMain instance.
447 $e: Exception object.
448
449 'ApiRsdServiceApis': Add or remove APIs from the RSD services list. Each service
450 should have its own entry in the $apis array and have a unique name, passed as
451 key for the array that represents the service data. In this data array, the
452 key-value-pair identified by the apiLink key is required.
453 &$apis: array of services
454
455 'ApiTokensGetTokenTypes': Use this hook to extend action=tokens with new token
456 types.
457 &$tokenTypes: supported token types in format 'type' => callback function
458 used to retrieve this type of tokens.
459
460 'ArticleAfterFetchContent': After fetching content of an article from the
461 database. DEPRECATED, use ArticleAfterFetchContentObject instead.
462 $article: the article (object) being loaded from the database
463 &$content: the content (string) of the article
464
465 'ArticleAfterFetchContentObject': After fetching content of an article from the
466 database.
467 $article: the article (object) being loaded from the database
468 &$content: the content of the article, as a Content object
469
470 'ArticleConfirmDelete': Before writing the confirmation form for article
471 deletion.
472 $article: the article (object) being deleted
473 $output: the OutputPage object
474 &$reason: the reason (string) the article is being deleted
475
476 'ArticleContentOnDiff': Before showing the article content below a diff. Use
477 this to change the content in this area or how it is loaded.
478 $diffEngine: the DifferenceEngine
479 $output: the OutputPage object
480
481 'ArticleDelete': Before an article is deleted.
482 $wikiPage: the WikiPage (object) being deleted
483 $user: the user (object) deleting the article
484 $reason: the reason (string) the article is being deleted
485 $error: if the deletion was prohibited, the (raw HTML) error message to display
486 (added in 1.13)
487 $status: Status object, modify this to throw an error. Overridden by $error
488 (added in 1.20)
489
490 'ArticleDeleteComplete': After an article is deleted.
491 $wikiPage: the WikiPage that was deleted
492 $user: the user that deleted the article
493 $reason: the reason the article was deleted
494 $id: id of the article that was deleted
495 $content: the Content of the deleted page
496 $logEntry: the ManualLogEntry used to record the deletion
497
498 'ArticleEditUpdateNewTalk': Before updating user_newtalk when a user talk page
499 was changed.
500 &$wikiPage: WikiPage (object) of the user talk page
501 $recipient: User (object) who's talk page was edited
502
503 'ArticleEditUpdates': When edit updates (mainly link tracking) are made when an
504 article has been changed.
505 $wikiPage: the WikiPage (object)
506 $editInfo: data holder that includes the parser output ($editInfo->output) for
507 that page after the change
508 $changed: bool for if the page was changed
509
510 'ArticleEditUpdatesDeleteFromRecentchanges': Before deleting old entries from
511 recentchanges table, return false to not delete old entries.
512 $wikiPage: WikiPage (object) being modified
513
514 'ArticleFromTitle': when creating an article object from a title object using
515 Wiki::articleFromTitle().
516 $title: Title (object) used to create the article object
517 $article: Article (object) that will be returned
518
519 'ArticleInsertComplete': After a new article is created. DEPRECATED, use
520 PageContentInsertComplete.
521 $wikiPage: WikiPage created
522 $user: User creating the article
523 $text: New content
524 $summary: Edit summary/comment
525 $isMinor: Whether or not the edit was marked as minor
526 $isWatch: (No longer used)
527 $section: (No longer used)
528 $flags: Flags passed to WikiPage::doEditContent()
529 $revision: New Revision of the article
530
531 'ArticleMergeComplete': After merging to article using Special:Mergehistory.
532 $targetTitle: target title (object)
533 $destTitle: destination title (object)
534
535 'ArticlePageDataAfter': After loading data of an article from the database.
536 $wikiPage: WikiPage (object) whose data were loaded
537 $row: row (object) returned from the database server
538
539 'ArticlePageDataBefore': Before loading data of an article from the database.
540 $wikiPage: WikiPage (object) that data will be loaded
541 $fields: fields (array) to load from the database
542
543 'ArticlePrepareTextForEdit': Called when preparing text to be saved.
544 $wikiPage: the WikiPage being saved
545 $popts: parser options to be used for pre-save transformation
546
547 'ArticleProtect': Before an article is protected.
548 $wikiPage: the WikiPage being protected
549 $user: the user doing the protection
550 $protect: boolean whether this is a protect or an unprotect
551 $reason: Reason for protect
552 $moveonly: boolean whether this is for move only or not
553
554 'ArticleProtectComplete': After an article is protected.
555 $wikiPage: the WikiPage that was protected
556 $user: the user who did the protection
557 $protect: boolean whether it was a protect or an unprotect
558 $reason: Reason for protect
559 $moveonly: boolean whether it was for move only or not
560
561 'ArticlePurge': Before executing "&action=purge".
562 $wikiPage: WikiPage (object) to purge
563
564 'ArticleRevisionVisibilitySet': Called when changing visibility of one or more
565 revisions of an article.
566 &$title: Title object of the article
567
568 'ArticleRevisionUndeleted': After an article revision is restored.
569 $title: the article title
570 $revision: the revision
571 $oldPageID: the page ID of the revision when archived (may be null)
572
573 'ArticleRollbackComplete': After an article rollback is completed.
574 $wikiPage: the WikiPage that was edited
575 $user: the user who did the rollback
576 $revision: the revision the page was reverted back to
577 $current: the reverted revision
578
579 'ArticleSave': Before an article is saved. DEPRECATED, use PageContentSave
580 instead.
581 $wikiPage: the WikiPage (object) being saved
582 $user: the user (object) saving the article
583 $text: the new article text
584 $summary: the article summary (comment)
585 $isminor: minor flag
586 $iswatch: watch flag
587 $section: section #
588
589 'ArticleSaveComplete': After an article has been updated. DEPRECATED, use
590 PageContentSaveComplete instead.
591 $wikiPage: WikiPage modified
592 $user: User performing the modification
593 $text: New content
594 $summary: Edit summary/comment
595 $isMinor: Whether or not the edit was marked as minor
596 $isWatch: (No longer used)
597 $section: (No longer used)
598 $flags: Flags passed to WikiPage::doEditContent()
599 $revision: New Revision of the article
600 $status: Status object about to be returned by doEditContent()
601 $baseRevId: the rev ID (or false) this edit was based on
602
603 'ArticleUndelete': When one or more revisions of an article are restored.
604 $title: Title corresponding to the article restored
605 $create: Whether or not the restoration caused the page to be created (i.e. it
606 didn't exist before).
607 $comment: The comment associated with the undeletion.
608
609 'ArticleUndeleteLogEntry': When a log entry is generated but not yet saved.
610 $pageArchive: the PageArchive object
611 &$logEntry: ManualLogEntry object
612 $user: User who is performing the log action
613
614 'ArticleUpdateBeforeRedirect': After a page is updated (usually on save), before
615 the user is redirected back to the page.
616 &$article: the article
617 &$sectionanchor: The section anchor link (e.g. "#overview" )
618 &$extraq: Extra query parameters which can be added via hooked functions
619
620 'ArticleViewFooter': After showing the footer section of an ordinary page view
621 $article: Article object
622 $patrolFooterShown: boolean whether patrol footer is shown
623
624 'ArticleViewHeader': Before the parser cache is about to be tried for article
625 viewing.
626 &$article: the article
627 &$pcache: whether to try the parser cache or not
628 &$outputDone: whether the output for this page finished or not. Set to a ParserOutput
629 object to both indicate that the output is done and what parser output was used.
630
631 'ArticleViewRedirect': Before setting "Redirected from ..." subtitle when a
632 redirect was followed.
633 $article: target article (object)
634
635 'ArticleViewCustom': Allows to output the text of the article in a different
636 format than wikitext. DEPRECATED, use ArticleContentViewCustom instead. Note
637 that it is preferable to implement proper handing for a custom data type using
638 the ContentHandler facility.
639 $text: text of the page
640 $title: title of the page
641 $output: reference to $wgOut
642
643 'ArticleContentViewCustom': Allows to output the text of the article in a
644 different format than wikitext. Note that it is preferable to implement proper
645 handing for a custom data type using the ContentHandler facility.
646 $content: content of the page, as a Content object
647 $title: title of the page
648 $output: reference to $wgOut
649
650 'AuthPluginAutoCreate': Called when creating a local account for an user logged
651 in from an external authentication method.
652 $user: User object created locally
653
654 'AuthPluginSetup': Update or replace authentication plugin object ($wgAuth).
655 Gives a chance for an extension to set it programmatically to a variable class.
656 &$auth: the $wgAuth object, probably a stub
657
658 'AutopromoteCondition': Check autopromote condition for user.
659 $type: condition type
660 $args: arguments
661 $user: user
662 $result: result of checking autopromote condition
663
664 'BacklinkCacheGetPrefix': Allows to set prefix for a specific link table.
665 $table: table name
666 &$prefix: prefix
667
668 'BacklinkCacheGetConditions': Allows to set conditions for query when links to
669 certain title are fetched.
670 $table: table name
671 $title: title of the page to which backlinks are sought
672 &$conds: query conditions
673
674 'BadImage': When checking against the bad image list. Change $bad and return
675 false to override. If an image is "bad", it is not rendered inline in wiki
676 pages or galleries in category pages.
677 $name: Image name being checked
678 &$bad: Whether or not the image is "bad"
679
680 'BeforeDisplayNoArticleText': Before displaying message key "noarticletext" or
681 "noarticletext-nopermission" at Article::showMissingArticle().
682 $article: article object
683
684 'BeforeInitialize': Before anything is initialized in
685 MediaWiki::performRequest().
686 &$title: Title being used for request
687 $unused: null
688 &$output: OutputPage object
689 &$user: User
690 $request: WebRequest object
691 $mediaWiki: Mediawiki object
692
693 'BeforePageDisplay': Prior to outputting a page.
694 &$out: OutputPage object
695 &$skin: Skin object
696
697 'BeforePageRedirect': Prior to sending an HTTP redirect. Gives a chance to
698 override how the redirect is output by modifying, or by returning false and
699 taking over the output.
700 $out: OutputPage object
701 &$redirect: URL, modifiable
702 &$code: HTTP code (eg '301' or '302'), modifiable
703
704 'BeforeParserFetchFileAndTitle': Before an image is rendered by Parser.
705 $parser: Parser object
706 $nt: the image title
707 &$options: array of options to RepoGroup::findFile
708 &$descQuery: query string to add to thumbnail URL
709
710 FIXME: Where does the below sentence fit in?
711 If 'broken' is a key in $options then the file will appear as a broken thumbnail.
712
713 'BeforeParserFetchTemplateAndtitle': Before a template is fetched by Parser.
714 $parser: Parser object
715 $title: title of the template
716 &$skip: skip this template and link it?
717 &$id: the id of the revision being parsed
718
719 'BeforeParserrenderImageGallery': Before an image gallery is rendered by Parser.
720 &$parser: Parser object
721 &$ig: ImageGallery object
722
723 'BeforeWelcomeCreation': Before the welcomecreation message is displayed to a
724 newly created user.
725 &$welcome_creation_msg: MediaWiki message name to display on the welcome screen
726 to a newly created user account.
727 &$injected_html: Any HTML to inject after the "logged in" message of a newly
728 created user account
729
730 'BitmapHandlerTransform': before a file is transformed, gives extension the
731 possibility to transform it themselves
732 $handler: BitmapHandler
733 $image: File
734 &$scalerParams: Array with scaler parameters
735 &$mto: null, set to a MediaTransformOutput
736
737 'BitmapHandlerCheckImageArea': By BitmapHandler::normaliseParams, after all
738 normalizations have been performed, except for the $wgMaxImageArea check.
739 $image: File
740 &$params: Array of parameters
741 &$checkImageAreaHookResult: null, set to true or false to override the
742 $wgMaxImageArea check result.
743
744 'PerformRetroactiveAutoblock': Called before a retroactive autoblock is applied
745 to a user.
746 $block: Block object (which is set to be autoblocking)
747 &$blockIds: Array of block IDs of the autoblock
748
749 'BlockIp': Before an IP address or user is blocked.
750 $block: the Block object about to be saved
751 $user: the user _doing_ the block (not the one being blocked)
752
753 'BlockIpComplete': After an IP address or user is blocked.
754 $block: the Block object that was saved
755 $user: the user who did the block (not the one being blocked)
756
757 'BookInformation': Before information output on Special:Booksources.
758 $isbn: ISBN to show information for
759 $output: OutputPage object in use
760
761 'CanonicalNamespaces': For extensions adding their own namespaces or altering
762 the defaults.
763 Note that if you need to specify namespace protection or content model for
764 a namespace that is added in a CanonicalNamespaces hook handler, you
765 should do so by altering $wgNamespaceProtection and
766 $wgNamespaceContentModels outside the handler, in top-level scope. The
767 point at which the CanonicalNamespaces hook fires is too late for altering
768 these variables. This applies even if the namespace addition is
769 conditional; it is permissible to declare a content model and protection
770 for a namespace and then decline to actually register it.
771 &$namespaces: Array of namespace numbers with corresponding canonical names
772
773 'CategoryAfterPageAdded': After a page is added to a category.
774 $category: Category that page was added to
775 $wikiPage: WikiPage that was added
776
777 'CategoryAfterPageRemoved': After a page is removed from a category.
778 $category: Category that page was removed from
779 $wikiPage: WikiPage that was removed
780
781 'CategoryPageView': Before viewing a categorypage in CategoryPage::view.
782 $catpage: CategoryPage instance
783
784 'ChangePasswordForm': For extensions that need to add a field to the
785 ChangePassword form via the Preferences form.
786 &$extraFields: An array of arrays that hold fields like would be passed to the
787 pretty function.
788
789 'ChangesListInsertArticleLink': Override or augment link to article in RC list.
790 &$changesList: ChangesList instance.
791 &$articlelink: HTML of link to article (already filled-in).
792 &$s: HTML of row that is being constructed.
793 &$rc: RecentChange instance.
794 $unpatrolled: Whether or not we are showing unpatrolled changes.
795 $watched: Whether or not the change is watched by the user.
796
797 'Collation::factory': Called if $wgCategoryCollation is an unknown collation.
798 $collationName: Name of the collation in question
799 &$collationObject: Null. Replace with a subclass of the Collation class that
800 implements the collation given in $collationName.
801
802 'ConfirmEmailComplete': Called after a user's email has been confirmed
803 successfully.
804 $user: user (object) whose email is being confirmed
805
806 'ContentHandlerDefaultModelFor': Called when the default content model is determined
807 for a given title. May be used to assign a different model for that title.
808 $title: the Title in question
809 &$model: the model name. Use with CONTENT_MODEL_XXX constants.
810
811 'ContentHandlerForModelID': Called when a ContentHandler is requested for a given
812 content model name, but no entry for that model exists in $wgContentHandlers.
813 $modeName: the requested content model name
814 &$handler: set this to a ContentHandler object, if desired.
815
816 'ConvertContent': Called by AbstractContent::convert when a conversion to another
817 content model is requested.
818 $content: The Content object to be converted.
819 $toModel: The ID of the content model to convert to.
820 $lossy: boolean indicating whether lossy conversion is allowed.
821 &$result: Output parameter, in case the handler function wants to provide a
822 converted Content object. Note that $result->getContentModel() must return $toModel.
823 Handler functions that modify $result should generally return false to further
824 attempts at conversion.
825
826 'ContribsPager::getQueryInfo': Before the contributions query is about to run
827 &$pager: Pager object for contributions
828 &$queryInfo: The query for the contribs Pager
829
830 'ContribsPager::reallyDoQuery': Called before really executing the query for My Contributions
831 &$data: an array of results of all contribs queries
832 $pager: The ContribsPager object hooked into
833 $offset: Index offset, inclusive
834 $limit: Exact query limit
835 $descending: Query direction, false for ascending, true for descending
836
837 'ContributionsLineEnding': Called before a contributions HTML line is finished
838 $page: SpecialPage object for contributions
839 &$ret: the HTML line
840 $row: the DB row for this line
841 &$classes: the classes to add to the surrounding <li>
842
843 'ContributionsToolLinks': Change tool links above Special:Contributions
844 $id: User identifier
845 $title: User page title
846 &$tools: Array of tool links
847
848 'CustomEditor': When invoking the page editor
849 $article: Article being edited
850 $user: User performing the edit
851
852 Return true to allow the normal editor to be used, or false
853 if implementing a custom editor, e.g. for a special namespace,
854 etc.
855
856 'DatabaseOraclePostInit': Called after initialising an Oracle database
857 &$db: the DatabaseOracle object
858
859 'Debug': Called when outputting a debug log line via wfDebug() or wfDebugLog()
860 $text: plaintext string to be output
861 $group: null or a string naming a logging group (as defined in $wgDebugLogGroups)
862
863 'NewDifferenceEngine': Called when a new DifferenceEngine object is made
864 $title: the diff page title (nullable)
865 &$oldId: the actual old Id to use in the diff
866 &$newId: the actual new Id to use in the diff (0 means current)
867 $old: the ?old= param value from the url
868 $new: the ?new= param value from the url
869
870 'DiffRevisionTools': Override or extend the revision tools available from the
871 diff view, i.e. undo, etc.
872 $rev: Revision object
873 &$links: Array of HTML links
874
875 'DiffViewHeader': Called before diff display
876 $diff: DifferenceEngine object that's calling
877 $oldRev: Revision object of the "old" revision (may be null/invalid)
878 $newRev: Revision object of the "new" revision
879
880 'DisplayOldSubtitle': before creating subtitle when browsing old versions of
881 an article
882 $article: article (object) being viewed
883 $oldid: oldid (int) being viewed
884
885 'DoEditSectionLink': Override the HTML generated for section edit links
886 $skin: Skin object rendering the UI
887 $title: Title object for the title being linked to (may not be the same as
888 $wgTitle, if the section is included from a template)
889 $section: The designation of the section being pointed to, to be included in
890 the link, like "&section=$section"
891 $tooltip: The default tooltip. Escape before using.
892 By default, this is wrapped in the 'editsectionhint' message.
893 &$result: The HTML to return, prefilled with the default plus whatever other
894 changes earlier hooks have made
895 $lang: The language code to use for the link in the wfMessage function
896
897 'EditFilter': Perform checks on an edit
898 $editor: EditPage instance (object). The edit form (see includes/EditPage.php)
899 $text: Contents of the edit box
900 $section: Section being edited
901 &$error: Error message to return
902 $summary: Edit summary for page
903
904 'EditFilterMerged': Post-section-merge edit filter.
905 DEPRECATED, use EditFilterMergedContent instead.
906 $editor: EditPage instance (object)
907 $text: content of the edit box
908 &$error: error message to return
909 $summary: Edit summary for page
910
911 'EditFilterMergedContent': Post-section-merge edit filter.
912 This may be triggered by the EditPage or any other facility that modifies page content.
913 Use the $status object to indicate whether the edit should be allowed, and to provide
914 a reason for disallowing it. Return false to abort the edit, and true to continue.
915 Returning true if $status->isOK() returns false means "don't save but continue user
916 interaction", e.g. show the edit form.
917 $context: object implementing the IContextSource interface.
918 $content: content of the edit box, as a Content object.
919 $status: Status object to represent errors, etc.
920 $summary: Edit summary for page
921 $user: the User object representing the user whois performing the edit.
922 $minoredit: whether the edit was marked as minor by the user.
923
924 'EditFormPreloadText': Allows population of the edit form when creating
925 new pages
926 &$text: Text to preload with
927 &$title: Title object representing the page being created
928
929 'EditFormInitialText': Allows modifying the edit form when editing existing
930 pages
931 $editPage: EditPage object
932
933 'EditPage::attemptSave': Called before an article is
934 saved, that is before WikiPage::doEditContent() is called
935 $editpage_Obj: the current EditPage object
936
937 'EditPage::importFormData': allow extensions to read additional data
938 posted in the form
939 $editpage: EditPage instance
940 $request: Webrequest
941 return value is ignored (should always return true)
942
943 'EditPage::showEditForm:fields': allows injection of form field into edit form
944 $editor: the EditPage instance for reference
945 $out: an OutputPage instance to write to
946 return value is ignored (should always return true)
947
948 'EditPage::showEditForm:initial': before showing the edit form
949 $editor: EditPage instance (object)
950 $out: an OutputPage instance to write to
951
952 Return false to halt editing; you'll need to handle error messages, etc.
953 yourself. Alternatively, modifying $error and returning true will cause the
954 contents of $error to be echoed at the top of the edit form as wikitext.
955 Return true without altering $error to allow the edit to proceed.
956
957 'EditPage::showStandardInputs:options': allows injection of form fields into
958 the editOptions area
959 $editor: EditPage instance (object)
960 $out: an OutputPage instance to write to
961 &$tabindex: HTML tabindex of the last edit check/button
962 return value is ignored (should always be true)
963
964 'EditPageBeforeConflictDiff': allows modifying the EditPage object and output
965 when there's an edit conflict. Return false to halt normal diff output; in
966 this case you're responsible for computing and outputting the entire "conflict"
967 part, i.e., the "difference between revisions" and "your text" headers and
968 sections.
969 &$editor: EditPage instance
970 &$out: OutputPage instance
971
972 'EditPageBeforeEditButtons': Allows modifying the edit buttons below the
973 textarea in the edit form.
974 &$editpage: The current EditPage object
975 &$buttons: Array of edit buttons "Save", "Preview", "Live", and "Diff"
976 &$tabindex: HTML tabindex of the last edit check/button
977
978 'EditPageBeforeEditChecks': Allows modifying the edit checks below the textarea
979 in the edit form.
980 &$editpage: The current EditPage object
981 &$checks: Array of edit checks like "watch this page"/"minor edit"
982 &$tabindex: HTML tabindex of the last edit check/button
983
984 'EditPageBeforeEditToolbar': Allows modifying the edit toolbar above the
985 textarea in the edit form.
986 &$toolbar: The toolbar HTMl
987
988 'EditPageCopyrightWarning': Allow for site and per-namespace customization of
989 contribution/copyright notice.
990 $title: title of page being edited
991 &$msg: localization message name, overridable. Default is either
992 'copyrightwarning' or 'copyrightwarning2'.
993
994 'EditPageGetDiffText': DEPRECATED. Use EditPageGetDiffContent instead. Allow
995 modifying the wikitext that will be used in "Show changes". Note that it is
996 preferable to implement diff handling for different data types using the
997 ContentHandler facility.
998 $editPage: EditPage object
999 &$newtext: wikitext that will be used as "your version"
1000
1001 'EditPageGetDiffContent': Allow modifying the wikitext that will be used in
1002 "Show changes". Note that it is preferable to implement diff handling for
1003 different data types using the ContentHandler facility.
1004 $editPage: EditPage object
1005 &$newtext: wikitext that will be used as "your version"
1006
1007 'EditPageGetPreviewText': DEPRECATED. Use EditPageGetPreviewContent instead.
1008 Allow modifying the wikitext that will be previewed. Note that it is preferable
1009 to implement previews for different data types using the ContentHandler
1010 facility.
1011 $editPage: EditPage object
1012 &$toparse: wikitext that will be parsed
1013
1014 'EditPageGetPreviewContent': Allow modifying the wikitext that will be
1015 previewed. Note that it is preferable to implement previews for different data
1016 types using the ContentHandler facility.
1017 $editPage: EditPage object
1018 &$content: Content object to be previewed (may be replaced by hook function)
1019
1020 'EditPageNoSuchSection': When a section edit request is given for an non-existent section
1021 &$editpage: The current EditPage object
1022 &$res: the HTML of the error text
1023
1024 'EditPageTosSummary': Give a chance for site and per-namespace customizations
1025 of terms of service summary link that might exist separately from the copyright
1026 notice.
1027 $title: title of page being edited
1028 &$msg: localization message name, overridable. Default is 'editpage-tos-summary'
1029
1030 'EmailConfirmed': When checking that the user's email address is "confirmed".
1031 $user: User being checked
1032 $confirmed: Whether or not the email address is confirmed
1033 This runs before the other checks, such as anonymity and the real check; return
1034 true to allow those checks to occur, and false if checking is done.
1035
1036 'EmailUser': Before sending email from one user to another.
1037 $to: address of receiving user
1038 $from: address of sending user
1039 $subject: subject of the mail
1040 $text: text of the mail
1041
1042 'EmailUserCC': Before sending the copy of the email to the author.
1043 $to: address of receiving user
1044 $from: address of sending user
1045 $subject: subject of the mail
1046 $text: text of the mail
1047
1048 'EmailUserComplete': After sending email from one user to another.
1049 $to: address of receiving user
1050 $from: address of sending user
1051 $subject: subject of the mail
1052 $text: text of the mail
1053
1054 'EmailUserForm': After building the email user form object.
1055 $form: HTMLForm object
1056
1057 'EmailUserPermissionsErrors': to retrieve permissions errors for emailing a
1058 user.
1059 $user: The user who is trying to email another user.
1060 $editToken: The user's edit token.
1061 &$hookErr: Out-param for the error. Passed as the parameters to
1062 OutputPage::showErrorPage.
1063
1064 'ExemptFromAccountCreationThrottle': Exemption from the account creation
1065 throttle.
1066 $ip: The ip address of the user
1067
1068 'ExtensionTypes': Called when generating the extensions credits, use this to
1069 change the tables headers.
1070 &$extTypes: associative array of extensions types
1071
1072 'ExtractThumbParameters': Called when extracting thumbnail parameters from a
1073 thumbnail file name.
1074 $thumbname: the base name of the thumbnail file
1075 &$params: the currently extracted params (has source name, temp or archived zone)
1076
1077 'FetchChangesList': When fetching the ChangesList derivative for a particular
1078 user.
1079 $user: User the list is being fetched for
1080 &$skin: Skin object to be used with the list
1081 &$list: List object (defaults to NULL, change it to an object instance and
1082 return false override the list derivative used)
1083
1084 'FileDeleteComplete': When a file is deleted.
1085 $file: reference to the deleted file
1086 $oldimage: in case of the deletion of an old image, the name of the old file
1087 $article: in case all revisions of the file are deleted a reference to the
1088 WikiFilePage associated with the file.
1089 $user: user who performed the deletion
1090 $reason: reason
1091
1092 'FileTransformed': When a file is transformed and moved into storage.
1093 $file: reference to the File object
1094 $thumb: the MediaTransformOutput object
1095 $tmpThumbPath: The temporary file system path of the transformed file
1096 $thumbPath: The permanent storage path of the transformed file
1097
1098 'FileUpload': When a file upload occurs.
1099 $file : Image object representing the file that was uploaded
1100 $reupload : Boolean indicating if there was a previously another image there or
1101 not (since 1.17)
1102 $hasDescription : Boolean indicating that there was already a description page
1103 and a new one from the comment wasn't created (since 1.17)
1104
1105 'FileUndeleteComplete': When a file is undeleted
1106 $title: title object to the file
1107 $fileVersions: array of undeleted versions. Empty if all versions were restored
1108 $user: user who performed the undeletion
1109 $reason: reason
1110
1111 'FormatAutocomments': When an autocomment is formatted by the Linker.
1112 &$comment: Reference to the accumulated comment. Initially null, when set the
1113 default code will be skipped.
1114 $pre: Initial part of the parsed comment before the call to the hook.
1115 $auto: The extracted part of the parsed comment before the call to the hook.
1116 $post: The final part of the parsed comment before the call to the hook.
1117 $title: An optional title object used to links to sections. Can be null.
1118 $local: Boolean indicating whether section links should refer to local page.
1119
1120 'GalleryGetModes': Get list of classes that can render different modes of a
1121 gallery
1122 $modeArray: An associative array mapping mode names to classes that implement
1123 that mode. It is expected all registered classes are a subclass of
1124 ImageGalleryBase.
1125
1126 'GetAutoPromoteGroups': When determining which autopromote groups a user is
1127 entitled to be in.
1128 &$user: user to promote.
1129 &$promote: groups that will be added.
1130
1131 'GetBlockedStatus': after loading blocking status of an user from the database
1132 $user: user (object) being checked
1133
1134 'GetCacheVaryCookies': Get cookies that should vary cache options.
1135 $out: OutputPage object
1136 &$cookies: array of cookies name, add a value to it if you want to add a cookie
1137 that have to vary cache options
1138
1139 'GetCanonicalURL': Modify fully-qualified URLs used for IRC and e-mail
1140 notifications.
1141 $title: Title object of page
1142 $url: string value as output (out parameter, can modify)
1143 $query: query options passed to Title::getCanonicalURL()
1144
1145 'GetDefaultSortkey': Override the default sortkey for a page.
1146 $title: Title object that we need to get a sortkey for
1147 &$sortkey: Sortkey to use.
1148
1149 'GetDoubleUnderscoreIDs': Modify the list of behavior switch (double
1150 underscore) magic words. Called by MagicWord.
1151 &$doubleUnderscoreIDs: array of strings
1152
1153 'GetFullURL': Modify fully-qualified URLs used in redirects/export/offsite data.
1154 $title: Title object of page
1155 $url: string value as output (out parameter, can modify)
1156 $query: query options passed to Title::getFullURL()
1157
1158 'GetHumanTimestamp': Pre-emptively override the human-readable timestamp generated
1159 by MWTimestamp::getHumanTimestamp(). Return false in this hook to use the custom
1160 output.
1161 &$output: string for the output timestamp
1162 $timestamp: MWTimestamp object of the current (user-adjusted) timestamp
1163 $relativeTo: MWTimestamp object of the relative (user-adjusted) timestamp
1164 $user: User whose preferences are being used to make timestamp
1165 $lang: Language that will be used to render the timestamp
1166
1167 'GetInternalURL': Modify fully-qualified URLs used for squid cache purging.
1168 $title: Title object of page
1169 $url: string value as output (out parameter, can modify)
1170 $query: query options passed to Title::getInternalURL()
1171
1172 'GetIP': modify the ip of the current user (called only once).
1173 &$ip: string holding the ip as determined so far
1174
1175 'GetLinkColours': modify the CSS class of an array of page links.
1176 $linkcolour_ids: array of prefixed DB keys of the pages linked to,
1177 indexed by page_id.
1178 &$colours: (output) array of CSS classes, indexed by prefixed DB keys
1179
1180 'GetLocalURL': Modify local URLs as output into page links. Note that if you are
1181 working with internal urls (non-interwiki) then it may be preferable to work
1182 with the GetLocalURL::Internal or GetLocalURL::Article hooks as GetLocalURL can
1183 be buggy for internal urls on render if you do not re-implement the horrible
1184 hack that Title::getLocalURL uses in your own extension.
1185 $title: Title object of page
1186 &$url: string value as output (out parameter, can modify)
1187 $query: query options passed to Title::getLocalURL()
1188
1189 'GetLocalURL::Internal': Modify local URLs to internal pages.
1190 $title: Title object of page
1191 &$url: string value as output (out parameter, can modify)
1192 $query: query options passed to Title::getLocalURL()
1193
1194 'GetLocalURL::Article': Modify local URLs specifically pointing to article paths
1195 without any fancy queries or variants.
1196 $title: Title object of page
1197 &$url: string value as output (out parameter, can modify)
1198
1199 'GetMetadataVersion': Modify the image metadata version currently in use. This
1200 is used when requesting image metadata from a ForeignApiRepo. Media handlers
1201 that need to have versioned metadata should add an element to the end of the
1202 version array of the form 'handler_name=version'. Most media handlers won't need
1203 to do this unless they broke backwards compatibility with a previous version of
1204 the media handler metadata output.
1205 &$version: Array of version strings
1206
1207 'GetNewMessagesAlert': Disable or modify the new messages alert
1208 &$newMessagesAlert: An empty string by default. If the user has new talk page
1209 messages, this should be populated with an alert message to that effect
1210 $newtalks: An empty array if the user has no new messages or an array containing
1211 links and revisions if there are new messages (See User::getNewMessageLinks)
1212 $user: The user object of the user who is loading the page
1213 $out: OutputPage object (to check what type of page the user is on)
1214
1215 'GetPreferences': Modify user preferences.
1216 $user: User whose preferences are being modified.
1217 &$preferences: Preferences description array, to be fed to an HTMLForm object
1218
1219 'getUserPermissionsErrors': Add a permissions error when permissions errors are
1220 checked for. Use instead of userCan for most cases. Return false if the user
1221 can't do it, and populate $result with the reason in the form of
1222 array( messagename, param1, param2, ... ). For consistency, error messages
1223 should be plain text with no special coloring, bolding, etc. to show that
1224 they're errors; presenting them properly to the user as errors is done by the
1225 caller.
1226 $title: Title object being checked against
1227 $user : Current user object
1228 $action: Action being checked
1229 $result: User permissions error to add. If none, return true.
1230
1231 'getUserPermissionsErrorsExpensive': Equal to getUserPermissionsErrors, but is
1232 called only if expensive checks are enabled. Add a permissions error when
1233 permissions errors are checked for. Return false if the user can't do it, and
1234 populate $result with the reason in the form of array( messagename, param1,
1235 param2, ... ). For consistency, error messages should be plain text with no
1236 special coloring, bolding, etc. to show that they're errors; presenting them
1237 properly to the user as errors is done by the caller.
1238
1239 $title: Title object being checked against
1240 $user : Current user object
1241 $action: Action being checked
1242 $result: User permissions error to add. If none, return true.
1243
1244 'GitViewers': Called when generating the list of git viewers for
1245 Special:Version, use this to change the list.
1246 &$extTypes: associative array of repo URLS to viewer URLs.
1247
1248 'HistoryRevisionTools': Override or extend the revision tools available from the
1249 page history view, i.e. undo, rollback, etc.
1250 $rev: Revision object
1251 &$links: Array of HTML links
1252
1253 'ImageBeforeProduceHTML': Called before producing the HTML created by a wiki
1254 image insertion. You can skip the default logic entirely by returning false, or
1255 just modify a few things using call-by-reference.
1256 &$skin: Skin object
1257 &$title: Title object of the image
1258 &$file: File object, or false if it doesn't exist
1259 &$frameParams: Various parameters with special meanings; see documentation in
1260 includes/Linker.php for Linker::makeImageLink
1261 &$handlerParams: Various parameters with special meanings; see documentation in
1262 includes/Linker.php for Linker::makeImageLink
1263 &$time: Timestamp of file in 'YYYYMMDDHHIISS' string form, or false for current
1264 &$res: Final HTML output, used if you return false
1265
1266
1267 'ImageOpenShowImageInlineBefore': Call potential extension just before showing
1268 the image on an image page.
1269 $imagePage: ImagePage object ($this)
1270 $output: $wgOut
1271
1272 'ImagePageAfterImageLinks': Called after the image links section on an image
1273 page is built.
1274 $imagePage: ImagePage object ($this)
1275 &$html: HTML for the hook to add
1276
1277 'ImagePageFileHistoryLine': Called when a file history line is constructed.
1278 $file: the file
1279 $line: the HTML of the history line
1280 $css: the line CSS class
1281
1282 'ImagePageFindFile': Called when fetching the file associated with an image
1283 page.
1284 $page: ImagePage object
1285 &$file: File object
1286 &$displayFile: displayed File object
1287
1288 'ImagePageShowTOC': Called when the file toc on an image page is generated.
1289 $page: ImagePage object
1290 &$toc: Array of <li> strings
1291
1292 'ImgAuthBeforeStream': executed before file is streamed to user, but only when
1293 using img_auth.php.
1294 &$title: the Title object of the file as it would appear for the upload page
1295 &$path: the original file and path name when img_auth was invoked by the the web
1296 server
1297 &$name: the name only component of the file
1298 &$result: The location to pass back results of the hook routine (only used if
1299 failed)
1300 $result[0]=The index of the header message
1301 $result[1]=The index of the body text message
1302 $result[2 through n]=Parameters passed to body text message. Please note the
1303 header message cannot receive/use parameters.
1304
1305 'ImportHandleLogItemXMLTag': When parsing a XML tag in a log item.
1306 $reader: XMLReader object
1307 $logInfo: Array of information
1308 Return false to stop further processing of the tag
1309
1310 'ImportHandlePageXMLTag': When parsing a XML tag in a page.
1311 $reader: XMLReader object
1312 $pageInfo: Array of information
1313 Return false to stop further processing of the tag
1314
1315 'ImportHandleRevisionXMLTag': When parsing a XML tag in a page revision.
1316 $reader: XMLReader object
1317 $pageInfo: Array of page information
1318 $revisionInfo: Array of revision information
1319 Return false to stop further processing of the tag
1320
1321 'ImportHandleToplevelXMLTag': When parsing a top level XML tag.
1322 $reader: XMLReader object
1323 Return false to stop further processing of the tag
1324
1325 'ImportHandleUploadXMLTag': When parsing a XML tag in a file upload.
1326 $reader: XMLReader object
1327 $revisionInfo: Array of information
1328 Return false to stop further processing of the tag
1329
1330 'InfoAction': When building information to display on the action=info page.
1331 $context: IContextSource object
1332 &$pageInfo: Array of information
1333
1334 'InitializeArticleMaybeRedirect': MediaWiki check to see if title is a redirect.
1335 $title: Title object ($wgTitle)
1336 $request: WebRequest
1337 $ignoreRedirect: boolean to skip redirect check
1338 $target: Title/string of redirect target
1339 $article: Article object
1340
1341 'InterwikiLoadPrefix': When resolving if a given prefix is an interwiki or not.
1342 Return true without providing an interwiki to continue interwiki search.
1343 $prefix: interwiki prefix we are looking for.
1344 &$iwData: output array describing the interwiki with keys iw_url, iw_local,
1345 iw_trans and optionally iw_api and iw_wikiid.
1346
1347 'InternalParseBeforeSanitize': during Parser's internalParse method just before
1348 the parser removes unwanted/dangerous HTML tags and after nowiki/noinclude/
1349 includeonly/onlyinclude and other processings. Ideal for syntax-extensions after
1350 template/parser function execution which respect nowiki and HTML-comments.
1351 &$parser: Parser object
1352 &$text: string containing partially parsed text
1353 &$stripState: Parser's internal StripState object
1354
1355 'InternalParseBeforeLinks': during Parser's internalParse method before links
1356 but after nowiki/noinclude/includeonly/onlyinclude and other processings.
1357 &$parser: Parser object
1358 &$text: string containing partially parsed text
1359 &$stripState: Parser's internal StripState object
1360
1361 'InvalidateEmailComplete': Called after a user's email has been invalidated
1362 successfully.
1363 $user: user (object) whose email is being invalidated
1364
1365 'IRCLineURL': When constructing the URL to use in an IRC notification.
1366 Callee may modify $url and $query, URL will be constructed as $url . $query
1367 &$url: URL to index.php
1368 &$query: Query string
1369
1370 'IsFileCacheable': Override the result of Article::isFileCacheable() (if true)
1371 $article: article (object) being checked
1372
1373 'IsTrustedProxy': Override the result of wfIsTrustedProxy()
1374 $ip: IP being check
1375 $result: Change this value to override the result of wfIsTrustedProxy()
1376
1377 'IsUploadAllowedFromUrl': Override the result of UploadFromUrl::isAllowedUrl()
1378 $url: URL used to upload from
1379 &$allowed: Boolean indicating if uploading is allowed for given URL
1380
1381 'isValidEmailAddr': Override the result of User::isValidEmailAddr(), for
1382 instance to return false if the domain name doesn't match your organization.
1383 $addr: The e-mail address entered by the user
1384 &$result: Set this and return false to override the internal checks
1385
1386 'isValidPassword': Override the result of User::isValidPassword()
1387 $password: The password entered by the user
1388 &$result: Set this and return false to override the internal checks
1389 $user: User the password is being validated for
1390
1391 'Language::getMessagesFileName':
1392 $code: The language code or the language we're looking for a messages file for
1393 &$file: The messages file path, you can override this to change the location.
1394
1395 'LanguageGetNamespaces': Provide custom ordering for namespaces or
1396 remove namespaces. Do not use this hook to add namespaces. Use
1397 CanonicalNamespaces for that.
1398 &$namespaces: Array of namespaces indexed by their numbers
1399
1400 'LanguageGetMagic': DEPRECATED, use $magicWords in a file listed in
1401 $wgExtensionMessagesFiles instead.
1402 Use this to define synonyms of magic words depending of the language
1403 $magicExtensions: associative array of magic words synonyms
1404 $lang: language code (string)
1405
1406 'LanguageGetSpecialPageAliases': DEPRECATED, use $specialPageAliases in a file
1407 listed in $wgExtensionMessagesFiles instead.
1408 Use to define aliases of special pages names depending of the language
1409 $specialPageAliases: associative array of magic words synonyms
1410 $lang: language code (string)
1411
1412 'LanguageGetTranslatedLanguageNames': Provide translated language names.
1413 &$names: array of language code => language name
1414 $code language of the preferred translations
1415
1416 'LanguageLinks': Manipulate a page's language links. This is called
1417 in various places to allow extensions to define the effective language
1418 links for a page.
1419 $title: The page's Title.
1420 &$links: Associative array mapping language codes to prefixed links of the
1421 form "language:title".
1422 &$linkFlags: Associative array mapping prefixed links to arrays of flags.
1423 Currently unused, but planned to provide support for marking individual
1424 language links in the UI, e.g. for featured articles.
1425
1426 'LinkBegin': Used when generating internal and interwiki links in
1427 Linker::link(), before processing starts. Return false to skip default
1428 processing and return $ret. See documentation for Linker::link() for details on
1429 the expected meanings of parameters.
1430 $skin: the Skin object
1431 $target: the Title that the link is pointing to
1432 &$html: the contents that the <a> tag should have (raw HTML); null means
1433 "default".
1434 &$customAttribs: the HTML attributes that the <a> tag should have, in
1435 associative array form, with keys and values unescaped. Should be merged with
1436 default values, with a value of false meaning to suppress the attribute.
1437 &$query: the query string to add to the generated URL (the bit after the "?"),
1438 in associative array form, with keys and values unescaped.
1439 &$options: array of options. Can include 'known', 'broken', 'noclasses'.
1440 &$ret: the value to return if your hook returns false.
1441
1442 'LinkEnd': Used when generating internal and interwiki links in Linker::link(),
1443 just before the function returns a value. If you return true, an <a> element
1444 with HTML attributes $attribs and contents $html will be returned. If you
1445 return false, $ret will be returned.
1446 $skin: the Skin object
1447 $target: the Title object that the link is pointing to
1448 $options: the options. Will always include either 'known' or 'broken', and may
1449 include 'noclasses'.
1450 &$html: the final (raw HTML) contents of the <a> tag, after processing.
1451 &$attribs: the final HTML attributes of the <a> tag, after processing, in
1452 associative array form.
1453 &$ret: the value to return if your hook returns false.
1454
1455 'LinkerMakeExternalImage': At the end of Linker::makeExternalImage() just
1456 before the return.
1457 &$url: the image url
1458 &$alt: the image's alt text
1459 &$img: the new image HTML (if returning false)
1460
1461 'LinkerMakeExternalLink': At the end of Linker::makeExternalLink() just
1462 before the return.
1463 &$url: the link url
1464 &$text: the link text
1465 &$link: the new link HTML (if returning false)
1466 &$attribs: the attributes to be applied.
1467 $linkType: The external link type
1468
1469 'LinksUpdate': At the beginning of LinksUpdate::doUpdate() just before the
1470 actual update.
1471 &$linksUpdate: the LinksUpdate object
1472
1473 'LinksUpdateAfterInsert': At the end of LinksUpdate::incrTableUpdate() after
1474 each link table insert. For example, pagelinks, imagelinks, externallinks.
1475 $linksUpdate: LinksUpdate object
1476 $table: the table to insert links to
1477 $insertions: an array of links to insert
1478
1479 'LinksUpdateComplete': At the end of LinksUpdate::doUpdate() when updating,
1480 including delete and insert, has completed for all link tables
1481 &$linksUpdate: the LinksUpdate object
1482
1483 'LinksUpdateConstructed': At the end of LinksUpdate() is construction.
1484 &$linksUpdate: the LinksUpdate object
1485
1486 'ListDefinedTags': When trying to find all defined tags.
1487 &$tags: The list of tags.
1488
1489 'LoadExtensionSchemaUpdates': Called during database installation and updates.
1490 &updater: A DatabaseUpdater subclass
1491
1492 'LocalFile::getHistory': Called before file history query performed.
1493 $file: the File object
1494 $tables: tables
1495 $fields: select fields
1496 $conds: conditions
1497 $opts: query options
1498 $join_conds: JOIN conditions
1499
1500 'LocalFilePurgeThumbnails': Called before thumbnails for a local file a purged.
1501 $file: the File object
1502 $archiveName: name of an old file version or false if it's the current one
1503
1504 'LocalisationCacheRecache': Called when loading the localisation data into
1505 cache.
1506 $cache: The LocalisationCache object
1507 $code: language code
1508 &$alldata: The localisation data from core and extensions
1509
1510 'LogEventsListShowLogExtract': Called before the string is added to OutputPage.
1511 Returning false will prevent the string from being added to the OutputPage.
1512 &$s: html string to show for the log extract
1513 $types: String or Array Log types to show
1514 $page: String or Title The page title to show log entries for
1515 $user: String The user who made the log entries
1516 $param: Associative Array with the following additional options:
1517 - lim Integer Limit of items to show, default is 50
1518 - conds Array Extra conditions for the query (e.g. "log_action != 'revision'")
1519 - showIfEmpty boolean Set to false if you don't want any output in case the
1520 loglist is empty if set to true (default), "No matching items in log" is
1521 displayed if loglist is empty
1522 - msgKey Array If you want a nice box with a message, set this to the key of
1523 the message. First element is the message key, additional optional elements
1524 are parameters for the key that are processed with
1525 wfMessage()->params()->parseAsBlock()
1526 - offset Set to overwrite offset parameter in $wgRequest set to '' to unset
1527 offset
1528 - wrap String Wrap the message in html (usually something like
1529 "&lt;div ...>$1&lt;/div>").
1530 - flags Integer display flags (NO_ACTION_LINK,NO_EXTRA_USER_LINKS)
1531
1532 'LoginAuthenticateAudit': A login attempt for a valid user account either
1533 succeeded or failed. No return data is accepted; this hook is for auditing only.
1534 $user: the User object being authenticated against
1535 $password: the password being submitted and found wanting
1536 $retval: a LoginForm class constant with authenticateUserData() return
1537 value (SUCCESS, WRONG_PASS, etc.).
1538
1539 'LogLine': Processes a single log entry on Special:Log.
1540 $log_type: string for the type of log entry (e.g. 'move'). Corresponds to
1541 logging.log_type database field.
1542 $log_action: string for the type of log action (e.g. 'delete', 'block',
1543 'create2'). Corresponds to logging.log_action database field.
1544 $title: Title object that corresponds to logging.log_namespace and
1545 logging.log_title database fields.
1546 $paramArray: Array of parameters that corresponds to logging.log_params field.
1547 Note that only $paramArray[0] appears to contain anything.
1548 &$comment: string that corresponds to logging.log_comment database field, and
1549 which is displayed in the UI.
1550 &$revert: string that is displayed in the UI, similar to $comment.
1551 $time: timestamp of the log entry (added in 1.12)
1552
1553 'MaintenanceRefreshLinksInit': before executing the refreshLinks.php maintenance
1554 script.
1555 $refreshLinks: RefreshLinks object
1556
1557 'MagicWordwgVariableIDs': When defining new magic words IDs.
1558 $variableIDs: array of strings
1559
1560 'MakeGlobalVariablesScript': Called right before Skin::makeVariablesScript is
1561 executed. Ideally, this hook should only be used to add variables that depend on
1562 the current page/request; static configuration should be added through
1563 ResourceLoaderGetConfigVars instead.
1564 &$vars: variable (or multiple variables) to be added into the output of
1565 Skin::makeVariablesScript
1566 $out: The OutputPage which called the hook, can be used to get the real title.
1567
1568 'MarkPatrolled': Before an edit is marked patrolled.
1569 $rcid: ID of the revision to be marked patrolled
1570 $user: the user (object) marking the revision as patrolled
1571 $wcOnlySysopsCanPatrol: config setting indicating whether the user needs to be a
1572 sysop in order to mark an edit patrolled.
1573
1574 'MarkPatrolledComplete': After an edit is marked patrolled.
1575 $rcid: ID of the revision marked as patrolled
1576 $user: user (object) who marked the edit patrolled
1577 $wcOnlySysopsCanPatrol: config setting indicating whether the user must be a
1578 sysop to patrol the edit.
1579
1580 'MediaWikiPerformAction': Override MediaWiki::performAction(). Use this to do
1581 something completely different, after the basic globals have been set up, but
1582 before ordinary actions take place.
1583 $output: $wgOut
1584 $article: $wgArticle
1585 $title: $wgTitle
1586 $user: $wgUser
1587 $request: $wgRequest
1588 $mediaWiki: The $mediawiki object
1589
1590 'MessagesPreLoad': When loading a message from the database.
1591 $title: title of the message (string)
1592 $message: value (string), change it to the message you want to define
1593
1594 'MessageCacheReplace': When a message page is changed. Useful for updating
1595 caches.
1596 $title: name of the page changed.
1597 $text: new contents of the page.
1598
1599 'ModifyExportQuery': Modify the query used by the exporter.
1600 $db: The database object to be queried.
1601 &$tables: Tables in the query.
1602 &$conds: Conditions in the query.
1603 &$opts: Options for the query.
1604 &$join_conds: Join conditions for the query.
1605
1606 'MonoBookTemplateToolboxEnd': DEPRECATED. Called by Monobook skin after toolbox
1607 links have been rendered (useful for adding more). Note: this is only run for
1608 the Monobook skin. To add items to the toolbox you should use the
1609 SkinTemplateToolboxEnd hook instead, which works for all "SkinTemplate"-type
1610 skins.
1611 $tools: array of tools
1612
1613 'BaseTemplateToolbox': Called by BaseTemplate when building the $toolbox array
1614 and returning it for the skin to output. You can add items to the toolbox while
1615 still letting the skin make final decisions on skin-specific markup conventions
1616 using this hook.
1617 &$sk: The BaseTemplate base skin template
1618 &$toolbox: An array of toolbox items, see BaseTemplate::getToolbox and
1619 BaseTemplate::makeListItem for details on the format of individual items
1620 inside of this array.
1621
1622 'NamespaceIsMovable': Called when determining if it is possible to pages in a
1623 namespace.
1624 $index: Integer; the index of the namespace being checked.
1625 $result: Boolean; whether MediaWiki currently thinks that pages in this
1626 namespace are movable. Hooks may change this value to override the return
1627 value of MWNamespace::isMovable().
1628
1629 'NewRevisionFromEditComplete': Called when a revision was inserted due to an
1630 edit.
1631 $wikiPage: the WikiPage edited
1632 $rev: the new revision
1633 $baseID: the revision ID this was based off, if any
1634 $user: the editing user
1635
1636 'NormalizeMessageKey': Called before the software gets the text of a message
1637 (stuff in the MediaWiki: namespace), useful for changing WHAT message gets
1638 displayed.
1639 &$key: the message being looked up. Change this to something else to change
1640 what message gets displayed (string)
1641 &$useDB: whether or not to look up the message in the database (bool)
1642 &$langCode: the language code to get the message for (string) - or -
1643 whether to use the content language (true) or site language (false) (bool)
1644 &$transform: whether or not to expand variables and templates
1645 in the message (bool)
1646
1647 'OldChangesListRecentChangesLine': Customize entire recent changes line, or
1648 return false to omit the line from RecentChanges and Watchlist special pages.
1649 &$changeslist: The OldChangesList instance.
1650 &$s: HTML of the form "<li>...</li>" containing one RC entry.
1651 &$rc: The RecentChange object.
1652 &$classes: array of css classes for the <li> element
1653
1654 'OpenSearchUrls': Called when constructing the OpenSearch description XML. Hooks
1655 can alter or append to the array of URLs for search & suggestion formats.
1656 &$urls: array of associative arrays with Url element attributes
1657
1658 'OtherBlockLogLink': Get links to the block log from extensions which blocks
1659 users and/or IP addresses too.
1660 $otherBlockLink: An array with links to other block logs
1661 $ip: The requested IP address or username
1662
1663 'OutputPageBeforeHTML': A page has been processed by the parser and the
1664 resulting HTML is about to be displayed.
1665 $parserOutput: the parserOutput (object) that corresponds to the page
1666 $text: the text that will be displayed, in HTML (string)
1667
1668 'OutputPageBodyAttributes': Called when OutputPage::headElement is creating the
1669 body tag to allow for extensions to add attributes to the body of the page they
1670 might need. Or to allow building extensions to add body classes that aren't of
1671 high enough demand to be included in core.
1672 $out: The OutputPage which called the hook, can be used to get the real title
1673 $sk: The Skin that called OutputPage::headElement
1674 &$bodyAttrs: An array of attributes for the body tag passed to Html::openElement
1675
1676 'OutputPageCheckLastModified': when checking if the page has been modified
1677 since the last visit.
1678 &$modifiedTimes: array of timestamps.
1679 The following keys are set: page, user, epoch
1680
1681 'OutputPageParserOutput': after adding a parserOutput to $wgOut
1682 $out: OutputPage instance (object)
1683 $parserOutput: parserOutput instance being added in $out
1684
1685 'OutputPageMakeCategoryLinks': Links are about to be generated for the page's
1686 categories. Implementations should return false if they generate the category
1687 links, so the default link generation is skipped.
1688 $out: OutputPage instance (object)
1689 $categories: associative array, keys are category names, values are category
1690 types ("normal" or "hidden")
1691 $links: array, intended to hold the result. Must be an associative array with
1692 category types as keys and arrays of HTML links as values.
1693
1694 'PageContentInsertComplete': After a new article is created.
1695 $wikiPage: WikiPage created
1696 $user: User creating the article
1697 $content: New content as a Content object
1698 $summary: Edit summary/comment
1699 $isMinor: Whether or not the edit was marked as minor
1700 $isWatch: (No longer used)
1701 $section: (No longer used)
1702 $flags: Flags passed to WikiPage::doEditContent()
1703 $revision: New Revision of the article
1704
1705 'PageContentLanguage': Allows changing the language in which the content of a
1706 page is written. Defaults to the wiki content language ($wgContLang).
1707 $title: Title object
1708 &$pageLang: the page content language (either an object or a language code)
1709 $wgLang: the user language
1710
1711 'PageContentSave': Before an article is saved.
1712 $wikiPage: the WikiPage (object) being saved
1713 $user: the user (object) saving the article
1714 $content: the new article content, as a Content object
1715 $summary: the article summary (comment)
1716 $isminor: minor flag
1717 $iswatch: watch flag
1718 $section: section #
1719
1720 'PageContentSaveComplete': After an article has been updated.
1721 $wikiPage: WikiPage modified
1722 $user: User performing the modification
1723 $content: New content, as a Content object
1724 $summary: Edit summary/comment
1725 $isMinor: Whether or not the edit was marked as minor
1726 $isWatch: (No longer used)
1727 $section: (No longer used)
1728 $flags: Flags passed to WikiPage::doEditContent()
1729 $revision: New Revision of the article
1730 $status: Status object about to be returned by doEditContent()
1731 $baseRevId: the rev ID (or false) this edit was based on
1732
1733 'PageHistoryBeforeList': When a history page list is about to be constructed.
1734 $article: the article that the history is loading for
1735 $context: RequestContext object
1736
1737 'PageHistoryLineEnding' : Right before the end <li> is added to a history line.
1738 $row: the revision row for this line
1739 $s: the string representing this parsed line
1740 $classes: array containing the <li> element classes
1741
1742 'PageHistoryPager::getQueryInfo': when a history pager query parameter set is
1743 constructed.
1744 $pager: the pager
1745 $queryInfo: the query parameters
1746
1747 'PageRenderingHash': Alter the parser cache option hash key. A parser extension
1748 which depends on user options should install this hook and append its values to
1749 the key.
1750 $hash: reference to a hash key string which can be modified
1751
1752 'ParserAfterParse': Called from Parser::parse() just after the call to
1753 Parser::internalParse() returns.
1754 $parser: parser object
1755 $text: text being parsed
1756 $stripState: stripState used (object)
1757
1758 'ParserAfterStrip': Called at end of parsing time.
1759 TODO: No more strip, deprecated ?
1760 $parser: parser object
1761 $text: text being parsed
1762 $stripState: stripState used (object)
1763
1764 'ParserAfterTidy': Called after Parser::tidy() in Parser::parse()
1765 $parser: Parser object being used
1766 $text: text that will be returned
1767
1768 'ParserBeforeInternalParse': Called at the beginning of Parser::internalParse().
1769 $parser: Parser object
1770 $text: text to parse
1771 $stripState: StripState instance being used
1772
1773 'ParserBeforeStrip': Called at start of parsing time.
1774 TODO: No more strip, deprecated ?
1775 $parser: parser object
1776 $text: text being parsed
1777 $stripState: stripState used (object)
1778
1779 'ParserBeforeTidy': Called before tidy and custom tags replacements.
1780 $parser: Parser object being used
1781 $text: actual text
1782
1783 'ParserClearState': Called at the end of Parser::clearState().
1784 $parser: Parser object being cleared
1785
1786 'ParserCloned': Called when the parser is cloned.
1787 $parser: Newly-cloned Parser object
1788
1789 'ParserFirstCallInit': Called when the parser initialises for the first time.
1790 &$parser: Parser object being cleared
1791
1792 'ParserGetVariableValueSwitch': Called when the parser need the value of a
1793 custom magic word
1794 $parser: Parser object
1795 $varCache: array to store the value in case of multiples calls of the
1796 same magic word
1797 $index: index (string) of the magic
1798 $ret: value of the magic word (the hook should set it)
1799 $frame: PPFrame object to use for expanding any template variables
1800
1801 'ParserGetVariableValueTs': Use this to change the value of the time for the
1802 {{LOCAL...}} magic word.
1803 $parser: Parser object
1804 $time: actual time (timestamp)
1805
1806 'ParserGetVariableValueVarCache': use this to change the value of the variable
1807 cache or return false to not use it.
1808 $parser: Parser object
1809 $varCache: variable cache (array)
1810
1811 'ParserLimitReport': DEPRECATED, use ParserLimitReportPrepare and
1812 ParserLimitReportFormat instead.
1813 Called at the end of Parser:parse() when the parser will
1814 include comments about size of the text parsed.
1815 $parser: Parser object
1816 &$limitReport: text that will be included (without comment tags)
1817
1818 'ParserLimitReportFormat': Called for each row in the parser limit report that
1819 needs formatting. If nothing handles this hook, the default is to use "$key" to
1820 get the label, and "$key-value" or "$key-value-text"/"$key-value-html" to
1821 format the value.
1822 $key: Key for the limit report item (string)
1823 $value: Value of the limit report item
1824 &$report: String onto which to append the data
1825 $isHTML: If true, $report is an HTML table with two columns; if false, it's
1826 text intended for display in a monospaced font.
1827 $localize: If false, $report should be output in English.
1828
1829 'ParserLimitReportPrepare': Called at the end of Parser:parse() when the parser will
1830 include comments about size of the text parsed. Hooks should use
1831 $output->setLimitReportData() to populate data.
1832 $parser: Parser object
1833 $output: ParserOutput object
1834
1835 'ParserMakeImageParams': Called before the parser make an image link, use this
1836 to modify the parameters of the image.
1837 $title: title object representing the file
1838 $file: file object that will be used to create the image
1839 &$params: 2-D array of parameters
1840 $parser: Parser object that called the hook
1841
1842 'ParserSectionCreate': Called each time the parser creates a document section
1843 from wikitext. Use this to apply per-section modifications to HTML (like
1844 wrapping the section in a DIV). Caveat: DIVs are valid wikitext, and a DIV
1845 can begin in one section and end in another. Make sure your code can handle
1846 that case gracefully. See the EditSectionClearerLink extension for an example.
1847 $parser: the calling Parser instance
1848 $section: the section number, zero-based, but section 0 is usually empty
1849 &$sectionContent: ref to the content of the section. modify this.
1850 $showEditLinks: boolean describing whether this section has an edit link
1851
1852 'ParserTestParser': Called when creating a new instance of Parser in
1853 tests/parser/parserTest.inc.
1854 $parser: Parser object created
1855
1856 'ParserTestGlobals': Allows to define globals for parser tests.
1857 &$globals: Array with all the globals which should be set for parser tests.
1858 The arrays keys serve as the globals names, its values are the globals values.
1859
1860 'ParserTestTables': Alter the list of tables to duplicate when parser tests are
1861 run. Use when page save hooks require the presence of custom tables to ensure
1862 that tests continue to run properly.
1863 &$tables: array of table names
1864
1865 'PersonalUrls': Alter the user-specific navigation links (e.g. "my page,
1866 my talk page, my contributions" etc).
1867 &$personal_urls: Array of link specifiers (see SkinTemplate.php)
1868 &$title: Title object representing the current page
1869
1870 'PingLimiter': Allows extensions to override the results of User::pingLimiter().
1871 &$user : User performing the action
1872 $action : Action being performed
1873 &$result : Whether or not the action should be prevented
1874 Change $result and return false to give a definitive answer, otherwise
1875 the built-in rate limiting checks are used, if enabled.
1876
1877 'PlaceNewSection': Override placement of new sections. Return false and put the
1878 merged text into $text to override the default behavior.
1879 $wikipage : WikiPage object
1880 $oldtext : the text of the article before editing
1881 $subject : subject of the new section
1882 &$text : text of the new section
1883
1884 'PreferencesGetLegend': Override the text used for the <legend> of a
1885 preferences section.
1886 $form: the PreferencesForm object. This is a ContextSource as well
1887 $key: the section name
1888 &$legend: the legend text. Defaults to wfMessage( "prefs-$key" )->text() but may be overridden
1889
1890 'PrefixSearchBackend': Override the title prefix search used for OpenSearch and
1891 AJAX search suggestions. Put results into &$results outparam and return false.
1892 $ns : array of int namespace keys to search in
1893 $search : search term (not guaranteed to be conveniently normalized)
1894 $limit : maximum number of results to return
1895 &$results : out param: array of page names (strings)
1896
1897 'PrefsEmailAudit': Called when user changes their email address.
1898 $user: User (object) changing his email address
1899 $oldaddr: old email address (string)
1900 $newaddr: new email address (string)
1901
1902 'PrefsPasswordAudit': Called when user changes his password.
1903 $user: User (object) changing his password
1904 $newPass: new password
1905 $error: error (string) 'badretype', 'wrongpassword', 'error' or 'success'
1906
1907 'ProtectionForm::buildForm': Called after all protection type fieldsets are made
1908 in the form.
1909 $article: the title being (un)protected
1910 $output: a string of the form HTML so far
1911
1912 'ProtectionForm::save': Called when a protection form is submitted.
1913 $article: the title being (un)protected
1914 $errorMsg: an html message string of an error or an array of message name and
1915 its parameters
1916
1917 'ProtectionForm::showLogExtract': Called after the protection log extract is
1918 shown.
1919 $article: the page the form is shown for
1920 $out: OutputPage object
1921
1922 'RawPageViewBeforeOutput': Right before the text is blown out in action=raw.
1923 &$obj: RawPage object
1924 &$text: The text that's going to be the output
1925
1926 'RecentChange_save': Called at the end of RecentChange::save().
1927 $recentChange: RecentChange object
1928
1929 'RedirectSpecialArticleRedirectParams': Lets you alter the set of parameter
1930 names such as "oldid" that are preserved when using redirecting special pages
1931 such as Special:MyPage and Special:MyTalk.
1932 &$redirectParams: An array of parameters preserved by redirecting special pages.
1933
1934 'RequestContextCreateSkin': Called when RequestContext::getSkin creates a skin
1935 instance. Can be used by an extension override what skin is used in certain
1936 contexts.
1937 IContextSource $context: The RequestContext the skin is being created for.
1938 &$skin: A variable reference you may set a Skin instance or string key on to
1939 override the skin that will be used for the context.
1940
1941 'ResetSessionID': Called from wfResetSessionID
1942 $oldSessionID: old session id
1943 $newSessionID: new session id
1944
1945 'ResourceLoaderGetConfigVars': Called at the end of
1946 ResourceLoaderStartUpModule::getConfig(). Use this to export static
1947 configuration variables to JavaScript. Things that depend on the current page
1948 or request state must be added through MakeGlobalVariablesScript instead.
1949 &$vars: array( variable name => value )
1950
1951 'ResourceLoaderGetStartupModules': Run once the startup module is being
1952 generated. This allows you to add modules to the startup module. This hook
1953 should be used sparingly since any module added here will be loaded on all
1954 pages. This hook is useful if you want to make code available to module loader
1955 scripts.
1956
1957 'ResourceLoaderRegisterModules': Right before modules information is required,
1958 such as when responding to a resource
1959 loader request or generating HTML output.
1960 &$resourceLoader: ResourceLoader object
1961
1962 'ResourceLoaderTestModules': Let you add new JavaScript testing modules. This is
1963 called after the addition of 'qunit' and MediaWiki testing resources.
1964 &testModules: array of JavaScript testing modules. The 'qunit' framework,
1965 included in core, is fed using tests/qunit/QUnitTestResources.php.
1966 &ResourceLoader object
1967
1968 To add a new qunit module named 'myext.tests':
1969 testModules['qunit']['myext.tests'] = array(
1970 'script' => 'extension/myext/tests.js',
1971 'dependencies' => <any module dependency you might have>
1972 );
1973 For QUnit framework, the mediawiki.tests.qunit.testrunner dependency will be
1974 added to any module.
1975
1976 'RevisionInsertComplete': Called after a revision is inserted into the database.
1977 &$revision: the Revision
1978 $data: the data stored in old_text. The meaning depends on $flags: if external
1979 is set, it's the URL of the revision text in external storage; otherwise,
1980 it's the revision text itself. In either case, if gzip is set, the revision
1981 text is gzipped.
1982 $flags: a comma-delimited list of strings representing the options used. May
1983 include: utf8 (this will always be set for new revisions); gzip; external.
1984
1985 'SearchGetNearMatchBefore': Perform exact-title-matches in "go" searches before
1986 the normal operations.
1987 $allSearchTerms : Array of the search terms in all content languages
1988 &$titleResult : Outparam; the value to return. A Title object or null.
1989
1990 'SearchAfterNoDirectMatch': If there was no match for the exact result. This
1991 runs before lettercase variants are attempted, whereas 'SearchGetNearMatch'
1992 runs after.
1993 $term : Search term string
1994 &$title : Outparam; set to $title object and return false for a match
1995
1996 'SearchGetNearMatch': An extra chance for exact-title-matches in "go" searches
1997 if nothing was found.
1998 $term : Search term string
1999 &$title : Outparam; set to $title object and return false for a match
2000
2001 'SearchGetNearMatchComplete': A chance to modify exact-title-matches in "go"
2002 searches.
2003 $term : Search term string
2004 &$title : Current Title object that is being returned (null if none found).
2005
2006 'SearchEngineReplacePrefixesComplete': Run after SearchEngine::replacePrefixes().
2007 $searchEngine : The SearchEngine object. Users of this hooks will be interested
2008 in the $searchEngine->namespaces array.
2009 $query : Original query.
2010 &$parsed : Resultant query with the prefixes stripped.
2011
2012 'SearchResultInitFromTitle': Set the revision used when displaying a page in
2013 search results.
2014 $title : Current Title object being displayed in search results.
2015 &$id: Revision ID (default is false, for latest)
2016
2017 'SearchableNamespaces': An option to modify which namespaces are searchable.
2018 &$arr : Array of namespaces ($nsId => $name) which will be used.
2019
2020 'SetupAfterCache': Called in Setup.php, after cache objects are set
2021
2022 'ShowMissingArticle': Called when generating the output for a non-existent page.
2023 $article: The article object corresponding to the page
2024
2025 'ShowRawCssJs': Customise the output of raw CSS and JavaScript in page views.
2026 DEPRECATED, use the ContentHandler facility to handle CSS and JavaScript!
2027 $text: Text being shown
2028 $title: Title of the custom script/stylesheet page
2029 $output: Current OutputPage object
2030
2031 'ShowSearchHitTitle': Customise display of search hit title/link.
2032 &$title: Title to link to
2033 &$text: Text to use for the link
2034 $result: The search result
2035 $terms: The search terms entered
2036 $page: The SpecialSearch object.
2037
2038 'ShowSearchHit': Customize display of search hit.
2039 $searchPage: The SpecialSearch instance.
2040 $result: The SearchResult to show
2041 $terms: Search terms, for highlighting
2042 &$link: HTML of link to the matching page. May be modified.
2043 &$redirect: HTML of redirect info. May be modified.
2044 &$section: HTML of matching section. May be modified.
2045 &$extract: HTML of content extract. May be modified.
2046 &$score: HTML of score. May be modified.
2047 &$size: HTML of page size. May be modified.
2048 &$date: HTML of of page modification date. May be modified.
2049 &$related: HTML of additional info for the matching page. May be modified.
2050 &$html: May be set to the full HTML that should be used to represent the search
2051 hit. Must include the <li> ... </li> tags. Will only be used if the hook
2052 function returned false.
2053
2054 'SiteNoticeBefore': Before the sitenotice/anonnotice is composed. Return true to
2055 allow the normal method of notice selection/rendering to work, or change the
2056 value of $siteNotice and return false to alter it.
2057 &$siteNotice: HTML returned as the sitenotice
2058 $skin: Skin object
2059
2060 'SiteNoticeAfter': After the sitenotice/anonnotice is composed.
2061 &$siteNotice: HTML sitenotice. Alter the contents of $siteNotice to add to/alter
2062 the sitenotice/anonnotice.
2063 $skin: Skin object
2064
2065 'SkinAfterBottomScripts': At the end of Skin::bottomScripts().
2066 $skin: Skin object
2067 &$text: bottomScripts Text. Append to $text to add additional text/scripts after
2068 the stock bottom scripts.
2069
2070 'SkinAfterContent': Allows extensions to add text after the page content and
2071 article metadata. This hook should work in all skins. Set the &$data variable to
2072 the text you're going to add.
2073 &$data: (string) Text to be printed out directly (without parsing)
2074 $skin: Skin object
2075
2076 'SkinBuildSidebar': At the end of Skin::buildSidebar().
2077 $skin: Skin object
2078 &$bar: Sidebar contents
2079 Modify $bar to add or modify sidebar portlets.
2080
2081 'SkinCopyrightFooter': Allow for site and per-namespace customization of
2082 copyright notice.
2083 $title: displayed page title
2084 $type: 'normal' or 'history' for old/diff views
2085 &$msg: overridable message; usually 'copyright' or 'history_copyright'. This
2086 message must be in HTML format, not wikitext!
2087 &$link: overridable HTML link to be passed into the message as $1
2088 &$forContent: overridable flag if copyright footer is shown in content language.
2089
2090 'SkinGetPoweredBy': TODO
2091 &$text: additional 'powered by' icons in HTML. Note: Modern skin does not use
2092 the MediaWiki icon but plain text instead.
2093 $skin: Skin object
2094
2095 'SkinSubPageSubtitle': At the beginning of Skin::subPageSubtitle().
2096 &$subpages: Subpage links HTML
2097 $skin: Skin object
2098 $out: OutputPage object
2099 If false is returned $subpages will be used instead of the HTML
2100 subPageSubtitle() generates.
2101 If true is returned, $subpages will be ignored and the rest of
2102 subPageSubtitle() will run.
2103
2104 'SkinTemplateBuildNavUrlsNav_urlsAfterPermalink': After creating the "permanent
2105 link" tab.
2106 $sktemplate: SkinTemplate object
2107 $nav_urls: array of tabs
2108
2109 To alter the structured navigation links in SkinTemplates, there are three
2110 hooks called in different spots:
2111
2112 'SkinTemplateNavigation': Called on content pages after the tabs have been
2113 added, but before variants have been added.
2114 'SkinTemplateNavigation::SpecialPage': Called on special pages after the special
2115 tab is added but before variants have been added.
2116 'SkinTemplateNavigation::Universal': Called on both content and special pages
2117 after variants have been added.
2118 &$sktemplate: SkinTemplate object
2119 &$links: Structured navigation links. This is used to alter the navigation for
2120 skins which use buildNavigationUrls such as Vector.
2121
2122 'SkinTemplateOutputPageBeforeExec': Before SkinTemplate::outputPage() starts
2123 page output.
2124 &$sktemplate: SkinTemplate object
2125 &$tpl: Template engine object
2126
2127 'SkinTemplatePreventOtherActiveTabs': Use this to prevent showing active tabs.
2128 $sktemplate: SkinTemplate object
2129 $res: set to true to prevent active tabs
2130
2131 'SkinTemplateTabAction': Override SkinTemplate::tabAction().
2132 You can either create your own array, or alter the parameters for
2133 the normal one.
2134 &$sktemplate: The SkinTemplate instance.
2135 $title: Title instance for the page.
2136 $message: Visible label of tab.
2137 $selected: Whether this is a selected tab.
2138 $checkEdit: Whether or not the action=edit query should be added if appropriate.
2139 &$classes: Array of CSS classes to apply.
2140 &$query: Query string to add to link.
2141 &$text: Link text.
2142 &$result: Complete assoc. array if you want to return true.
2143
2144 'SkinTemplateToolboxEnd': Called by SkinTemplate skins after toolbox links have
2145 been rendered (useful for adding more).
2146 $sk: The QuickTemplate based skin template running the hook.
2147 $dummy: Called when SkinTemplateToolboxEnd is used from a BaseTemplate skin,
2148 extensions that add support for BaseTemplateToolbox should watch for this
2149 dummy parameter with "$dummy=false" in their code and return without echoing
2150 any HTML to avoid creating duplicate toolbox items.
2151
2152 'SoftwareInfo': Called by Special:Version for returning information about the
2153 software.
2154 $software: The array of software in format 'name' => 'version'. See
2155 SpecialVersion::softwareInformation().
2156
2157 'SpecialContributionsBeforeMainOutput': Before the form on Special:Contributions
2158 $id: User identifier
2159
2160 'SpecialListusersDefaultQuery': Called right before the end of
2161 UsersPager::getDefaultQuery().
2162 $pager: The UsersPager instance
2163 $query: The query array to be returned
2164
2165 'SpecialListusersFormatRow': Called right before the end of
2166 UsersPager::formatRow().
2167 $item: HTML to be returned. Will be wrapped in <li></li> after the hook finishes
2168 $row: Database row object
2169
2170 'SpecialListusersHeader': Called before closing the <fieldset> in
2171 UsersPager::getPageHeader().
2172 $pager: The UsersPager instance
2173 $out: The header HTML
2174
2175 'SpecialListusersHeaderForm': Called before adding the submit button in
2176 UsersPager::getPageHeader().
2177 $pager: The UsersPager instance
2178 $out: The header HTML
2179
2180 'SpecialListusersQueryInfo': Called right before the end of.
2181 UsersPager::getQueryInfo()
2182 $pager: The UsersPager instance
2183 $query: The query array to be returned
2184
2185 'SpecialMovepageAfterMove': Called after moving a page.
2186 $movePage: MovePageForm object
2187 $oldTitle: old title (object)
2188 $newTitle: new title (object)
2189
2190 'SpecialNewpagesConditions': Called when building sql query for
2191 Special:NewPages.
2192 &$special: NewPagesPager object (subclass of ReverseChronologicalPager)
2193 $opts: FormOptions object containing special page options
2194 &$conds: array of WHERE conditionals for query
2195 &tables: array of tables to be queried
2196 &$fields: array of columns to select
2197 &$join_conds: join conditions for the tables
2198
2199 'SpecialNewPagesFilters': Called after building form options at NewPages.
2200 $special: the special page object
2201 &$filters: associative array of filter definitions. The keys are the HTML
2202 name/URL parameters. Each key maps to an associative array with a 'msg'
2203 (message key) and a 'default' value.
2204
2205 'SpecialPage_initList': Called when setting up SpecialPage::$mList, use this
2206 hook to remove a core special page.
2207 $list: list (array) of core special pages
2208
2209 'SpecialPageAfterExecute': Called after SpecialPage::execute.
2210 $special: the SpecialPage object
2211 $subPage: the subpage string or null if no subpage was specified
2212
2213 'SpecialPageBeforeExecute': Called before SpecialPage::execute.
2214 $special: the SpecialPage object
2215 $subPage: the subpage string or null if no subpage was specified
2216
2217 'SpecialPasswordResetOnSubmit': When executing a form submission on
2218 Special:PasswordReset.
2219 $users: array of User objects.
2220 $data: array of data submitted by the user
2221 &$error: string, error code (message key) used to describe to error (out
2222 parameter). The hook needs to return false when setting this, otherwise it
2223 will have no effect.
2224
2225 'SpecialRandomGetRandomTitle': Called during the execution of Special:Random,
2226 use this to change some selection criteria or substitute a different title.
2227 &$randstr: The random number from wfRandom()
2228 &$isRedir: Boolean, whether to select a redirect or non-redirect
2229 &$namespaces: An array of namespace indexes to get the title from
2230 &$extra: An array of extra SQL statements
2231 &$title: If the hook returns false, a Title object to use instead of the
2232 result from the normal query
2233
2234 'SpecialRecentChangesFilters': Called after building form options at
2235 RecentChanges.
2236 $special: the special page object
2237 &$filters: associative array of filter definitions. The keys are the HTML
2238 name/URL parameters. Each key maps to an associative array with a 'msg'
2239 (message key) and a 'default' value.
2240
2241 'SpecialRecentChangesPanel': Called when building form options in
2242 SpecialRecentChanges.
2243 &$extraOpts: array of added items, to which can be added
2244 $opts: FormOptions for this request
2245
2246 'SpecialRecentChangesQuery': Called when building SQL query for
2247 SpecialRecentChanges and SpecialRecentChangesLinked.
2248 &$conds: array of WHERE conditionals for query
2249 &$tables: array of tables to be queried
2250 &$join_conds: join conditions for the tables
2251 $opts: FormOptions for this request
2252 &$query_options: array of options for the database request
2253 &$select: Array of columns to select
2254
2255 'SpecialResetTokensTokens': Called when building token list for
2256 SpecialResetTokens.
2257 &$tokens: array of token information arrays in the format of
2258 array( 'preference' => '<preference-name>', 'label-message' => '<message-key>' )
2259
2260 'SpecialSearchCreateLink': Called when making the message to create a page or
2261 go to the existing page.
2262 $t: title object searched for
2263 &$params: an array of the default message name and page title (as parameter)
2264
2265 'SpecialSearchGo': Called when user clicked the "Go".
2266 &$title: title object generated from the text entered by the user
2267 &$term: the search term entered by the user
2268
2269 'SpecialSearchNogomatch': Called when user clicked the "Go" button but the
2270 target doesn't exist.
2271 &$title: title object generated from the text entered by the user
2272
2273 'SpecialSearchPowerBox': The equivalent of SpecialSearchProfileForm for
2274 the advanced form, a.k.a. power search box.
2275 &$showSections: an array to add values with more options to
2276 $term: the search term (not a title object)
2277 $opts: an array of hidden options (containing 'redirs' and 'profile')
2278
2279 'SpecialSearchProfiles': Allows modification of search profiles.
2280 &$profiles: profiles, which can be modified.
2281
2282 'SpecialSearchProfileForm': Allows modification of search profile forms.
2283 $search: special page object
2284 &$form: String: form html
2285 $profile: String: current search profile
2286 $term: String: search term
2287 $opts: Array: key => value of hidden options for inclusion in custom forms
2288
2289 'SpecialSearchSetupEngine': Allows passing custom data to search engine.
2290 $search: SpecialSearch special page object
2291 $profile: String: current search profile
2292 $engine: the search engine
2293
2294 'SpecialSearchResultsPrepend': Called immediately before returning HTML
2295 on the search results page. Useful for including an external search
2296 provider. To disable the output of MediaWiki search output, return
2297 false.
2298 $specialSearch: SpecialSearch object ($this)
2299 $output: $wgOut
2300 $term: Search term specified by the user
2301
2302 'SpecialSearchResultsAppend': Called after all search results HTML has
2303 been output. Note that in some cases, this hook will not be called (no
2304 results, too many results, SpecialSearchResultsPrepend returned false,
2305 etc).
2306 $specialSearch: SpecialSearch object ($this)
2307 $output: $wgOut
2308 $term: Search term specified by the user
2309
2310 'SpecialSearchResults': Called before search result display when there are
2311 matches.
2312 $term: string of search term
2313 &$titleMatches: empty or SearchResultSet object
2314 &$textMatches: empty or SearchResultSet object
2315
2316 'SpecialSearchNoResults': Called before search result display when there are no
2317 matches.
2318 $term: string of search term
2319
2320 'SpecialStatsAddExtra': Add extra statistic at the end of Special:Statistics.
2321 &$extraStats: Array to save the new stats
2322 ( $extraStats['<name of statistic>'] => <value>; )
2323
2324 'SpecialUploadComplete': Called after successfully uploading a file from
2325 Special:Upload.
2326 $form: The SpecialUpload object
2327
2328 'SpecialVersionExtensionTypes': Called when generating the extensions credits,
2329 use this to change the tables headers.
2330 $extTypes: associative array of extensions types
2331
2332 'SpecialVersionVersionUrl': Called when building the URL for Special:Version.
2333 $wgVersion: Current $wgVersion for you to use
2334 &$versionUrl: Raw url to link to (eg: release notes)
2335
2336 'SpecialWatchlistFilters': Called after building form options at Watchlist.
2337 $special: the special page object
2338 &$filters: associative array of filter definitions. The keys are the HTML
2339 name/URL parameters. Each key maps to an associative array with a 'msg'
2340 (message key) and a 'default' value.
2341
2342 'SpecialWatchlistQuery': Called when building sql query for SpecialWatchlist.
2343 &$conds: array of WHERE conditionals for query
2344 &$tables: array of tables to be queried
2345 &$join_conds: join conditions for the tables
2346 &$fields: array of query fields
2347 $values: array of variables with watchlist options
2348
2349 'TestCanonicalRedirect': Called when about to force a redirect to a canonical
2350 URL for a title when we have no other parameters on the URL. Gives a chance for
2351 extensions that alter page view behavior radically to abort that redirect or
2352 handle it manually.
2353 $request: WebRequest
2354 $title: Title of the currently found title obj
2355 $output: OutputPage object
2356
2357 'ThumbnailBeforeProduceHTML': Called before an image HTML is about to be
2358 rendered (by ThumbnailImage:toHtml method).
2359 $thumbnail: the ThumbnailImage object
2360 &$attribs: image attribute array
2361 &$linkAttribs: image link attribute array
2362
2363 'TitleArrayFromResult': Called when creating an TitleArray object from a
2364 database result.
2365 &$titleArray: set this to an object to override the default object returned
2366 $res: database result used to create the object
2367
2368 'TitleQuickPermissions': Called from Title::checkQuickPermissions to add to
2369 or override the quick permissions check.
2370 $title: The Title object being accessed
2371 $user: The User performing the action
2372 $action: Action being performed
2373 &$errors: Array of errors
2374 $doExpensiveQueries: Whether to do expensive DB queries
2375 $short: Whether to return immediately on first error
2376
2377 'TitleGetEditNotices': Allows extensions to add edit notices
2378 $title: The Title object for the page the edit notices are for
2379 $oldid: Revision ID that the edit notices are for (or 0 for latest)
2380 &$notices: Array of notices. Keys are i18n message keys, values are parseAsBlock()ed messages.
2381
2382 'TitleGetRestrictionTypes': Allows extensions to modify the types of protection
2383 that can be applied.
2384 $title: The title in question.
2385 &$types: The types of protection available.
2386
2387 'TitleIsCssOrJsPage': Called when determining if a page is a CSS or JS page.
2388 $title: Title object that is being checked
2389 $result: Boolean; whether MediaWiki currently thinks this is a CSS/JS page.
2390 Hooks may change this value to override the return value of
2391 Title::isCssOrJsPage().
2392
2393 'TitleIsAlwaysKnown': Called when determining if a page exists. Allows
2394 overriding default behavior for determining if a page exists. If $isKnown is
2395 kept as null, regular checks happen. If it's a boolean, this value is returned
2396 by the isKnown method.
2397 $title: Title object that is being checked
2398 &$isKnown: Boolean|null; whether MediaWiki currently thinks this page is known
2399
2400 'TitleIsMovable': Called when determining if it is possible to move a page. Note
2401 that this hook is not called for interwiki pages or pages in immovable
2402 namespaces: for these, isMovable() always returns false.
2403 $title: Title object that is being checked
2404 $result: Boolean; whether MediaWiki currently thinks this page is movable.
2405 Hooks may change this value to override the return value of
2406 Title::isMovable().
2407
2408 'TitleIsWikitextPage': Called when determining if a page is a wikitext or should
2409 be handled by separate handler (via ArticleViewCustom).
2410 $title: Title object that is being checked
2411 $result: Boolean; whether MediaWiki currently thinks this is a wikitext page.
2412 Hooks may change this value to override the return value of
2413 Title::isWikitextPage()
2414
2415 'TitleMoveComplete': After moving an article (title).
2416 $old: old title
2417 $nt: new title
2418 $user: user who did the move
2419 $pageid: database ID of the page that's been moved
2420 $redirid: database ID of the created redirect
2421
2422 'TitleReadWhitelist': Called at the end of read permissions checks, just before
2423 adding the default error message if nothing allows the user to read the page. If
2424 a handler wants a title to *not* be whitelisted, it should also return false.
2425 $title: Title object being checked against
2426 $user: Current user object
2427 &$whitelisted: Boolean value of whether this title is whitelisted
2428
2429 'TitleSquidURLs': Called to determine which URLs to purge from HTTP caches.
2430 $this: Title object to purge
2431 &$urls: An array of URLs to purge from the caches, to be manipulated.
2432
2433 'UndeleteForm::showHistory': Called in UndeleteForm::showHistory, after a
2434 PageArchive object has been created but before any further processing is done.
2435 &$archive: PageArchive object
2436 $title: Title object of the page that we're viewing
2437
2438 'UndeleteForm::showRevision': Called in UndeleteForm::showRevision, after a
2439 PageArchive object has been created but before any further processing is done.
2440 &$archive: PageArchive object
2441 $title: Title object of the page that we're viewing
2442
2443 'UndeleteForm::undelete': Called un UndeleteForm::undelete, after checking that
2444 the site is not in read-only mode, that the Title object is not null and after
2445 a PageArchive object has been constructed but before performing any further
2446 processing.
2447 &$archive: PageArchive object
2448 $title: Title object of the page that we're about to undelete
2449
2450 'UndeleteShowRevision': Called when showing a revision in Special:Undelete.
2451 $title: title object related to the revision
2452 $rev: revision (object) that will be viewed
2453
2454 'UnknownAction': An unknown "action" has occurred (useful for defining your own
2455 actions).
2456 $action: action name
2457 $article: article "acted on"
2458
2459 'UnitTestsList': Called when building a list of files with PHPUnit tests.
2460 &$files: list of files
2461
2462 'UnwatchArticle': Before a watch is removed from an article.
2463 $user: user watching
2464 $page: WikiPage object to be removed
2465 &$status: Status object to be returned if the hook returns false
2466
2467 'UnwatchArticleComplete': After a watch is removed from an article.
2468 $user: user that watched
2469 $page: WikiPage object that was watched
2470
2471 'UpdateUserMailerFormattedPageStatus': Before notification email gets sent.
2472 $formattedPageStatus: list of valid page states
2473
2474 'UploadForm:initial': Before the upload form is generated. You might set the
2475 member-variables $uploadFormTextTop and $uploadFormTextAfterSummary to inject
2476 text (HTML) either before or after the editform.
2477 $form: UploadForm object
2478
2479 'UploadForm:BeforeProcessing': At the beginning of processUpload(). Lets you
2480 poke at member variables like $mUploadDescription before the file is saved. Do
2481 not use this hook to break upload processing. This will return the user to a
2482 blank form with no error message; use UploadVerification and UploadVerifyFile
2483 instead.
2484 $form: UploadForm object
2485
2486 'UploadCreateFromRequest': When UploadBase::createFromRequest has been called.
2487 $type: (string) the requested upload type
2488 &$className: the class name of the Upload instance to be created
2489
2490 'UploadComplete': when Upload completes an upload.
2491 &$upload: an UploadBase child instance
2492
2493 'UploadFormInitDescriptor': After the descriptor for the upload form as been
2494 assembled.
2495 $descriptor: (array) the HTMLForm descriptor
2496
2497 'UploadFormSourceDescriptors': after the standard source inputs have been
2498 added to the descriptor
2499 $descriptor: (array) the HTMLForm descriptor
2500
2501 'UploadVerification': Additional chances to reject an uploaded file. Consider
2502 using UploadVerifyFile instead.
2503 string $saveName: destination file name
2504 string $tempName: filesystem path to the temporary file for checks
2505 string &$error: output: message key for message to show if upload canceled by
2506 returning false. May also be an array, where the first element is the message
2507 key and the remaining elements are used as parameters to the message.
2508
2509 'UploadVerifyFile': extra file verification, based on mime type, etc. Preferred
2510 in most cases over UploadVerification.
2511 object $upload: an instance of UploadBase, with all info about the upload
2512 string $mime: The uploaded file's mime type, as detected by MediaWiki. Handlers
2513 will typically only apply for specific mime types.
2514 object &$error: output: true if the file is valid. Otherwise, an indexed array
2515 representing the problem with the file, where the first element is the message
2516 key and the remaining elements are used as parameters to the message.
2517
2518 'UploadComplete': Upon completion of a file upload.
2519 $uploadBase: UploadBase (or subclass) object. File can be accessed by
2520 $uploadBase->getLocalFile().
2521
2522 'User::mailPasswordInternal': before creation and mailing of a user's new
2523 temporary password
2524 $user: the user who sent the message out
2525 $ip: IP of the user who sent the message out
2526 $u: the account whose new password will be set
2527
2528 'UserAddGroup': Called when adding a group; return false to override
2529 stock group addition.
2530 $user: the user object that is to have a group added
2531 &$group: the group to add, can be modified
2532
2533 'UserArrayFromResult': Called when creating an UserArray object from a database
2534 result.
2535 &$userArray: set this to an object to override the default object returned
2536 $res: database result used to create the object
2537
2538 'userCan': To interrupt/advise the "user can do X to Y article" check. If you
2539 want to display an error message, try getUserPermissionsErrors.
2540 $title: Title object being checked against
2541 $user : Current user object
2542 $action: Action being checked
2543 $result: Pointer to result returned if hook returns false. If null is returned,
2544 userCan checks are continued by internal code.
2545
2546 'UserCanSendEmail': To override User::canSendEmail() permission check.
2547 $user: User (object) whose permission is being checked
2548 &$canSend: bool set on input, can override on output
2549
2550 'UserClearNewTalkNotification': Called when clearing the "You have new
2551 messages!" message, return false to not delete it.
2552 $user: User (object) that will clear the message
2553
2554 'UserComparePasswords': Called when checking passwords, return false to
2555 override the default password checks.
2556 &$hash: String of the password hash (from the database)
2557 &$password: String of the plaintext password the user entered
2558 &$userId: Integer of the user's ID or Boolean false if the user ID was not
2559 supplied
2560 &$result: If the hook returns false, this Boolean value will be checked to
2561 determine if the password was valid
2562
2563 'UserCreateForm': change to manipulate the login form
2564 $template: SimpleTemplate instance for the form
2565
2566 'UserCryptPassword': Called when hashing a password, return false to implement
2567 your own hashing method.
2568 &$password: String of the plaintext password to encrypt
2569 &$salt: String of the password salt or Boolean false if no salt is provided
2570 &$wgPasswordSalt: Boolean of whether the salt is used in the default hashing
2571 method
2572 &$hash: If the hook returns false, this String will be used as the hash
2573
2574 'UserEffectiveGroups': Called in User::getEffectiveGroups().
2575 $user: User to get groups for
2576 &$groups: Current effective groups
2577
2578 'UserGetAllRights': After calculating a list of all available rights.
2579 &$rights: Array of rights, which may be added to.
2580
2581 'UserGetDefaultOptions': After fetching the core default, this hook is run right
2582 before returning the options to the caller. Warning: This hook is called for
2583 every call to User::getDefaultOptions(), which means it's potentially called
2584 dozens or hundreds of times. You may want to cache the results of non-trivial
2585 operations in your hook function for this reason.
2586 &$defaultOptions: Array of preference keys and their default values.
2587
2588 'UserGetEmail': Called when getting an user email address.
2589 $user: User object
2590 &$email: email, change this to override local email
2591
2592 'UserGetEmailAuthenticationTimestamp': Called when getting the timestamp of
2593 email authentication.
2594 $user: User object
2595 &$timestamp: timestamp, change this to override local email authentication
2596 timestamp
2597
2598 'UserGetImplicitGroups': Called in User::getImplicitGroups().
2599 &$groups: List of implicit (automatically-assigned) groups
2600
2601 'UserGetLanguageObject': Called when getting user's interface language object.
2602 $user: User object
2603 &$code: Language code that will be used to create the object
2604 $context: RequestContext object
2605
2606 'UserGetReservedNames': Allows to modify $wgReservedUsernames at run time.
2607 &$reservedUsernames: $wgReservedUsernames
2608
2609 'UserGetRights': Called in User::getRights().
2610 $user: User to get rights for
2611 &$rights: Current rights
2612
2613 'UserIsBlockedFrom': Check if a user is blocked from a specific page (for
2614 specific block exemptions).
2615 $user: User in question
2616 $title: Title of the page in question
2617 &$blocked: Out-param, whether or not the user is blocked from that page.
2618 &$allowUsertalk: If the user is blocked, whether or not the block allows users
2619 to edit their own user talk pages.
2620
2621 'UserIsBlockedGlobally': Check if user is blocked on all wikis.
2622 &$user: User object
2623 $ip: User's IP address
2624 &$blocked: Whether the user is blocked, to be modified by the hook
2625
2626 'UserIsEveryoneAllowed': Check if all users are allowed some user right; return
2627 false if a UserGetRights hook might remove the named right.
2628 $right: The user right being checked
2629
2630 'UserLoadAfterLoadFromSession': Called to authenticate users on external or
2631 environmental means; occurs after session is loaded.
2632 $user: user object being loaded
2633
2634 'UserLoadDefaults': Called when loading a default user.
2635 $user: user object
2636 $name: user name
2637
2638 'UserLoadFromDatabase': Called when loading a user from the database.
2639 $user: user object
2640 &$s: database query object
2641
2642 'UserLoadFromSession': Called to authenticate users on external/environmental
2643 means; occurs before session is loaded.
2644 $user: user object being loaded
2645 &$result: set this to a boolean value to abort the normal authentication
2646 process
2647
2648 'UserLoadOptions': When user options/preferences are being loaded from the
2649 database.
2650 $user: User object
2651 &$options: Options, can be modified.
2652
2653 'UserLoginComplete': After a user has logged in.
2654 $user: the user object that was created on login
2655 $inject_html: Any HTML to inject after the "logged in" message.
2656
2657 'UserLoginForm': change to manipulate the login form
2658 $template: SimpleTemplate instance for the form
2659
2660 'UserLogout': Before a user logs out.
2661 $user: the user object that is about to be logged out
2662
2663 'UserLogoutComplete': After a user has logged out.
2664 $user: the user object _after_ logout (won't have name, ID, etc.)
2665 $inject_html: Any HTML to inject after the "logged out" message.
2666 $oldName: name of the user before logout (string)
2667
2668 'UserRemoveGroup': Called when removing a group; return false to override stock
2669 group removal.
2670 $user: the user object that is to have a group removed
2671 &$group: the group to be removed, can be modified
2672
2673 'UserRights': After a user's group memberships are changed.
2674 $user : User object that was changed
2675 $add : Array of strings corresponding to groups added
2676 $remove: Array of strings corresponding to groups removed
2677
2678 'UserRetrieveNewTalks': Called when retrieving "You have new messages!"
2679 message(s).
2680 $user: user retrieving new talks messages
2681 $talks: array of new talks page(s)
2682
2683 'UserSaveSettings': Called when saving user settings.
2684 $user: User object
2685
2686 'UserSaveOptions': Called just before saving user preferences/options.
2687 $user: User object
2688 &$options: Options, modifiable
2689
2690 'UserSetCookies': Called when setting user cookies.
2691 $user: User object
2692 &$session: session array, will be added to $_SESSION
2693 &$cookies: cookies array mapping cookie name to its value
2694
2695 'UserSetEmail': Called when changing user email address.
2696 $user: User object
2697 &$email: new email, change this to override new email address
2698
2699 'UserSetEmailAuthenticationTimestamp': Called when setting the timestamp of
2700 email authentication.
2701 $user: User object
2702 &$timestamp: new timestamp, change this to override local email
2703 authentication timestamp
2704
2705 'UserToolLinksEdit': Called when generating a list of user tool links, e.g.
2706 "Foobar (Talk | Contribs | Block)".
2707 $userId: User id of the current user
2708 $userText: User name of the current user
2709 &$items: Array of user tool links as HTML fragments
2710
2711 'WantedPages::getQueryInfo': Called in WantedPagesPage::getQueryInfo(), can be
2712 used to alter the SQL query which gets the list of wanted pages.
2713 &$wantedPages: WantedPagesPage object
2714 &$query: query array, see QueryPage::getQueryInfo() for format documentation
2715
2716 'WatchArticle': Before a watch is added to an article.
2717 $user: user that will watch
2718 $page: WikiPage object to be watched
2719 &$status: Status object to be returned if the hook returns false
2720
2721 'WatchArticleComplete': After a watch is added to an article.
2722 $user: user that watched
2723 $page: WikiPage object watched
2724
2725 'WatchlistEditorBuildRemoveLine': when building remove lines in
2726 Special:Watchlist/edit.
2727 &$tools: array of extra links
2728 $title: Title object
2729 $redirect: whether the page is a redirect
2730 $skin: Skin object
2731
2732 'WebRequestPathInfoRouter': While building the PathRouter to parse the
2733 REQUEST_URI.
2734 $router: The PathRouter instance
2735
2736 'WebResponseSetCookie': when setting a cookie in WebResponse::setcookie().
2737 Return false to prevent setting of the cookie.
2738 &$name: Cookie name passed to WebResponse::setcookie()
2739 &$value: Cookie value passed to WebResponse::setcookie()
2740 &$expire: Cookie expiration, as for PHP's setcookie()
2741 $options: Options passed to WebResponse::setcookie()
2742
2743 'WikiExporter::dumpStableQuery': Get the SELECT query for "stable" revisions
2744 dumps. One, and only one hook should set this, and return false.
2745 &$tables: Database tables to use in the SELECT query
2746 &$opts: Options to use for the query
2747 &$join: Join conditions
2748
2749 'WikiPageDeletionUpdates': manipulate the list of DataUpdates to be applied when
2750 a page is deleted. Called in WikiPage::getDeletionUpdates(). Note that updates
2751 specific to a content model should be provided by the respective Content's
2752 getDeletionUpdates() method.
2753 $page: the WikiPage
2754 $content: the Content to generate updates for
2755 &$updates: the array of DataUpdate objects. Hook function may want to add to it.
2756
2757 'wfShellWikiCmd': Called when generating a shell-escaped command line string to
2758 run a MediaWiki cli script.
2759 &$script: MediaWiki cli script path
2760 &$parameters: Array of arguments and options to the script
2761 &$options: Associative array of options, may contain the 'php' and 'wrapper'
2762 keys
2763
2764 'wgQueryPages': Called when initialising $wgQueryPages, use this to add new
2765 query pages to be updated with maintenance/updateSpecialPages.php.
2766 $query: $wgQueryPages itself
2767
2768 'XmlDumpWriterOpenPage': Called at the end of XmlDumpWriter::openPage, to allow
2769 extra metadata to be added.
2770 $obj: The XmlDumpWriter object.
2771 &$out: The output string.
2772 $row: The database row for the page.
2773 $title: The title of the page.
2774
2775 'XmlDumpWriterWriteRevision': Called at the end of a revision in an XML dump, to
2776 add extra metadata.
2777 $obj: The XmlDumpWriter object.
2778 &$out: The text being output.
2779 $row: The database row for the revision.
2780 $text: The revision text.
2781
2782 'XMPGetInfo': Called when obtaining the list of XMP tags to extract. Can be used
2783 to add additional tags to extract.
2784 &$items: Array containing information on which items to extract. See XMPInfo for
2785 details on the format.
2786
2787 'XMPGetResults': Called just before returning the results array of parsing xmp
2788 data. Can be used to post-process the results.
2789 &$data: Array of metadata sections (such as $data['xmp-general']) each section
2790 is an array of metadata tags returned (each tag is either a value, or an array
2791 of values).
2792
2793 More hooks might be available but undocumented, you can execute
2794 'php maintenance/findHooks.php' to find hidden ones.