page is saved. A wiki page is deleted. Often there are two events
associated with a single action: one before the code is run to make the
event happen, and one after. Each event has a name, preferably in
- CamelCase. For example, 'UserLogin', 'ArticleSave', 'ArticleSaveComplete',
- 'ArticleDelete'.
+ CamelCase. For example, 'UserLogin', 'PageContentSave',
+ 'PageContentSaveComplete', 'ArticleDelete'.
hook
A clump of code and data that should be run when an event happens. This can
The extra data is useful if we want to use the same function or object for
different purposes. For example:
- $wgHooks['ArticleSaveComplete'][] = array( 'ircNotify', 'TimStarling' );
- $wgHooks['ArticleSaveComplete'][] = array( 'ircNotify', 'brion' );
+ $wgHooks['PageContentSaveComplete'][] = array( 'ircNotify', 'TimStarling' );
+ $wgHooks['PageContentSaveComplete'][] = array( 'ircNotify', 'brion' );
This code would result in ircNotify being run twice when an article is saved:
once for 'TimStarling', and once for 'brion'.
(added in 1.13)
$status: Status object, modify this to throw an error. Overridden by $error
(added in 1.20)
+$suppress: Whether this is a suppression deletion or not (added in 1.27)
'ArticleDeleteAfterSuccess': Output after an article has been deleted.
$title: Title of the article that has been deleted.
'BaseTemplateAfterPortlet': After output of portlets, allow injecting
custom HTML after the section. Any uses of the hook need to handle escaping.
-$template BaseTemplate
+$template: BaseTemplate
$portlet: string portlet name
&$html: string
$reason: reason
'FileUpload': When a file upload occurs.
-$file : Image object representing the file that was uploaded
-$reupload : Boolean indicating if there was a previously another image there or
+$file: Image object representing the file that was uploaded
+$reupload: Boolean indicating if there was a previously another image there or
not (since 1.17)
-$hasDescription : Boolean indicating that there was already a description page
+$hasDescription: Boolean indicating that there was already a description page
and a new one from the comment wasn't created (since 1.17)
'FormatAutocomments': When an autocomment is formatted by the Linker.
'getUserPermissionsErrors': Add a permissions error when permissions errors are
checked for. Use instead of userCan for most cases. Return false if the user
can't do it, and populate $result with the reason in the form of
-array( messagename, param1, param2, ... ). For consistency, error messages
+array( messagename, param1, param2, ... ) or a MessageSpecifier instance (you
+might want to use ApiMessage to provide machine-readable details for the API).
+For consistency, error messages
should be plain text with no special coloring, bolding, etc. to show that
they're errors; presenting them properly to the user as errors is done by the
caller.
called only if expensive checks are enabled. Add a permissions error when
permissions errors are checked for. Return false if the user can't do it, and
populate $result with the reason in the form of array( messagename, param1,
-param2, ... ). For consistency, error messages should be plain text with no
+param2, ... ) or a MessageSpecifier instance (you might want to use ApiMessage
+to provide machine-readable details for the API). For consistency, error
+messages should be plain text with no
special coloring, bolding, etc. to show that they're errors; presenting them
properly to the user as errors is done by the caller.
$title: Title object being checked against
$user: the user (object) marking the revision as patrolled
$wcOnlySysopsCanPatrol: config setting indicating whether the user needs to be a
sysop in order to mark an edit patrolled.
+$auto true if the edit is being marked as patrolled automatically
'MarkPatrolledComplete': After an edit is marked patrolled.
$rcid: ID of the revision marked as patrolled
$user: user (object) who marked the edit patrolled
$wcOnlySysopsCanPatrol: config setting indicating whether the user must be a
sysop to patrol the edit.
+$auto true if the edit is being marked as patrolled automatically
'MediaWikiPerformAction': Override MediaWiki::performAction(). Use this to do
something completely different, after the basic globals have been set up, but
on the search results page. Useful for including a feedback link.
$specialSearch: SpecialSearch object ($this)
$output: $wgOut
+$term: Search term specified by the user
'SpecialSearchSetupEngine': Allows passing custom data to search engine.
$search: SpecialSearch special page object
$to: Array of MailAddress objects for the recipients
&$returnPath: The return address string
+'UserMailerSplitTo': Called in UserMailer::send() to give extensions a chance
+to split up an email with multiple the To: field into separate emails.
+$to: array of MailAddress objects; unset the ones which should be mailed separately
+
+'UserMailerTransformContent': Called in UserMailer::send() to change email contents.
+Extensions can block sending the email by returning false and setting $error.
+$to: array of MailAdresses of the targets
+$from: MailAddress of the sender
+&$body: email body, either a string (for plaintext emails) or an array with 'text' and 'html' keys
+&$error: should be set to an error message string
+
+'UserMailerTransformMessage': Called in UserMailer::send() to change email after it has gone through
+the MIME transform. Extensions can block sending the email by returning false and setting $error.
+$to: array of MailAdresses of the targets
+$from: MailAddress of the sender
+&$subject: email subject (not MIME encoded)
+&$headers: email headers (except To: and Subject:) as an array of header name => value pairs
+&$body: email body (in MIME format) as a string
+&$error: should be set to an error message string
+
'UserRemoveGroup': Called when removing a group; return false to override stock
group removal.
$user: the user object that is to have a group removed