stuff in our mainline code. Using hooks, the function becomes:
function showAnArticle( $article ) {
-
if ( Hooks::run( 'ArticleShow', array( &$article ) ) ) {
-
# code to actually show the article goes here
Hooks::run( 'ArticleShowComplete', array( &$article ) );
'ArticlePageDataBefore': Before loading data of an article from the database.
&$wikiPage: WikiPage (object) that data will be loaded
&$fields: fields (array) to load from the database
+&$tables: tables (array) to load from the database
+&$joinConds: join conditions (array) to load from the database
'ArticlePrepareTextForEdit': Called when preparing text to be saved.
$wikiPage: the WikiPage being saved
$create: Whether or not the restoration caused the page to be created (i.e. it
didn't exist before).
$comment: The comment associated with the undeletion.
-$oldPageId: ID of page previously deleted (from archive table)
+$oldPageId: ID of page previously deleted (from archive table). This ID will be used
+ for the restored page.
+$restoredPages: Set of page IDs that have revisions restored for this undelete,
+ with keys being page IDs and values are 'true'.
'ArticleUndeleteLogEntry': When a log entry is generated but not yet saved.
$pageArchive: the PageArchive object
in a Category page. Gives extensions the opportunity to batch load any
related data about the pages.
$type: The category type. Either 'page', 'file' or 'subcat'
-$res: Query result from DatabaseBase::select()
+$res: Query result from Wikimedia\Rdbms\IDatabase::select()
'CategoryViewer::generateLink': Before generating an output link allow
extensions opportunity to generate a more specific or relevant link.
$unpatrolled: Whether or not we are showing unpatrolled changes.
$watched: Whether or not the change is watched by the user.
-'ChangesListSpecialPageFilters': Called after building form options on pages
+'ChangesListSpecialPageFilters': DEPRECATED! Use 'ChangesListSpecialPageStructuredFilters'
+instead.
+Called after building form options on pages
inheriting from ChangesListSpecialPage (in core: RecentChanges,
RecentChangesLinked and Watchlist).
$special: ChangesListSpecialPage instance
'ChangesListSpecialPageQuery': Called when building SQL query on pages
inheriting from ChangesListSpecialPage (in core: RecentChanges,
RecentChangesLinked and Watchlist).
+Do not use this to implement individual filters if they are compatible with the
+ChangesListFilter and ChangesListFilterGroup structure.
+Instead, use sub-classes of those classes, in conjunction with the
+ChangesListSpecialPageStructuredFilters hook.
+This hook can be used to implement filters that do not implement that structure,
+or custom behavior that is not an individual filter.
$name: name of the special page, e.g. 'Watchlist'
&$tables: array of tables to be queried
&$fields: array of columns to select
&$join_conds: join conditions for the tables
$opts: FormOptions for this request
+'ChangesListSpecialPageStructuredFilters': Called to allow extensions to register
+filters for pages inheriting from ChangesListSpecialPage (in core: RecentChanges,
+RecentChangesLinked, and Watchlist). Generally, you will want to construct
+new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects.
+When constructing them, you specify which group they belong to. You can reuse
+existing groups (accessed through $special->getFilterGroup), or create your own
+(ChangesListBooleanFilterGroup or ChangesListStringOptionsFilterGroup).
+If you create new groups, you must register them with $special->registerFilterGroup.
+Note that this is called regardless of whether the user is currently using
+the new (structured) or old (unstructured) filter UI. If you want your boolean
+filter to show on both the new and old UI, specify all the supported fields.
+These include showHide, label, and description.
+See the constructor of each ChangesList* class for documentation of supported
+fields.
+$special: ChangesListSpecialPage instance
+
'ChangeTagAfterDelete': Called after a change tag has been deleted (that is,
removed from all revisions and log entries to which it was applied). This gives
extensions a chance to take it off their books.
$rc: RecentChange being tagged when the tagging accompanies the action or null
$user: User who performed the tagging when the tagging is subsequent to the action or null
+'ChangeTagsAllowedAdd': Called when checking if a user can add tags to a change.
+&$allowedTags: List of all the tags the user is allowed to add. Any tags the
+ user wants to add ($addTags) that are not in this array will cause it to fail.
+ You may add or remove tags to this array as required.
+$addTags: List of tags user intends to add.
+$user: User who is adding the tags.
+
'ChangeUserGroups': Called before user groups are changed.
$performer: The User who will perform the change
$user: The User whose groups will be changed
a given content model name, but no entry for that model exists in
$wgContentHandlers.
Note: if your extension implements additional models via this hook, please
-use GetContentModels hook to make them known to core.
+use GetContentModels hook to make them known to core.
$modeName: the requested content model name
&$handler: set this to a ContentHandler object, if desired.
&$ret: the HTML line
$row: the DB row for this line
&$classes: the classes to add to the surrounding <li>
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
'ContributionsToolLinks': Change tool links above Special:Contributions
$id: User identifier
&$ret: the HTML line
$row: the DB row for this line
&$classes: the classes to add to the surrounding <li>
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
'DifferenceEngineAfterLoadNewText': called in DifferenceEngine::loadNewText()
after the new revision's content has been loaded into the class member variable
&$buttons: Array of edit buttons "Save", "Preview", "Live", and "Diff"
&$tabindex: HTML tabindex of the last edit check/button
-'EditPageBeforeEditChecks': Allows modifying the edit checks below the textarea
-in the edit form.
+'EditPageBeforeEditChecks': DEPRECATED! Use 'EditPageGetCheckboxesDefinition' instead,
+or 'EditPage::showStandardInputs:options' if you don't actually care about checkboxes
+and just want to add some HTML to the page.
+Allows modifying the edit checks below the textarea in the edit form.
&$editpage: The current EditPage object
-&$checks: Array of edit checks like "watch this page"/"minor edit"
+&$checks: Array of the HTML for edit checks like "watch this page"/"minor edit"
&$tabindex: HTML tabindex of the last edit check/button
'EditPageBeforeEditToolbar': Allows modifying the edit toolbar above the
textarea in the edit form.
-&$toolbar: The toolbar HTMl
+&$toolbar: The toolbar HTML
+Hook subscribers can return false to avoid the default toolbar code being loaded.
'EditPageCopyrightWarning': Allow for site and per-namespace customization of
contribution/copyright notice.
&$msg: localization message name, overridable. Default is either
'copyrightwarning' or 'copyrightwarning2'.
+'EditPageGetCheckboxesDefinition': Allows modifying the edit checkboxes
+below the textarea in the edit form.
+$editpage: The current EditPage object
+&$checkboxes: Array of checkbox definitions. See EditPage::getCheckboxesDefinition()
+for the format.
+
'EditPageGetDiffContent': Allow modifying the wikitext that will be used in
"Show changes". Note that it is preferable to implement diff handling for
different data types using the ContentHandler facility.
$block: An array of RecentChange objects in that block
$rc: The RecentChange object for this line
&$classes: An array of classes to change
+&$attribs: associative array of other HTML attributes for the <tr> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
'EnhancedChangesListModifyBlockLineData': to alter data used to build
a non-grouped recent change line in EnhancedChangesList.
change the tables headers.
&$extTypes: associative array of extensions types
-'ExtractThumbParameters': DEPRECATED! Media handler should override
-MediaHandler::parseParamString instead.
-Called when extracting thumbnail parameters from a thumbnail file name.
-$thumbname: the base name of the thumbnail file
-&$params: the currently extracted params (has source name, temp or archived
-zone)
-
'FetchChangesList': When fetching the ChangesList derivative for a particular
user.
$user: User the list is being fetched for
'GetIP': modify the ip of the current user (called only once).
&$ip: string holding the ip as determined so far
+'GetLangPreferredVariant': Called in LanguageConverter#getPreferredVariant() to
+ allow fetching the language variant code from cookies or other such
+ alternative storage.
+&$req: language variant from the URL (string) or boolean false if no variant
+ was specified in the URL; the value of this variable comes from
+ LanguageConverter#getURLVariant()
+
'GetLinkColours': modify the CSS class of an array of page links.
$linkcolour_ids: array of prefixed DB keys of the pages linked to,
indexed by page_id.
Return false to stop further processing of the tag
$reader: XMLReader object
+'ImportHandleUnknownUser': When a user doesn't exist locally, this hook is called
+to give extensions an opportunity to auto-create it. If the auto-creation is
+successful, return false.
+$name: User name
+
'ImportHandleUploadXMLTag': When parsing a XML tag in a file upload.
Return false to stop further processing of the tag
$reader: XMLReader object
&$attribs: the attributes to be applied
&$ret: the value to return if your hook returns false
+'LogEventsListLineEnding': Called before a Special:Log line is finished
+$page: the LogEventsList object
+&$ret: the HTML line
+$entry: the DatabaseLogEntry object for this row
+&$classes: the classes to add to the surrounding <li>
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
+
+
'HtmlPageLinkRendererBegin':
Used when generating internal and interwiki links in
LinkRenderer, before processing starts. Return false to skip default
$old: the ?old= param value from the url
$new: the ?new= param value from the url
+'NewPagesLineEnding': Called before a NewPages line is finished.
+$page: the SpecialNewPages object
+&$ret: the HTML line
+$row: the database row for this page (the recentchanges record and a few extras - see
+ NewPagesPager::getQueryInfo)
+&$classes: the classes to add to the surrounding <li>
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
+
'NewRevisionFromEditComplete': Called when a revision was inserted due to an
edit.
$wikiPage: the WikiPage edited
&$changeslist: The OldChangesList instance.
&$s: HTML of the form "<li>...</li>" containing one RC entry.
$rc: The RecentChange object.
-&$classes: array of css classes for the <li> element
+&$classes: array of css classes for the <li> element.
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
'OpenSearchUrls': Called when constructing the OpenSearch description XML. Hooks
can alter or append to the array of URLs for search & suggestion formats.
$title: the Title of the rendered page.
$parserOutput: ParserOutput resulting from rendering the page.
+'OtherAutoblockLogLink': Get links to the autoblock log from extensions which
+autoblocks users and/or IP addresses too.
+&$otherBlockLink: An array with links to other autoblock logs
+
'OtherBlockLogLink': Get links to the block log from extensions which blocks
users and/or IP addresses too.
&$otherBlockLink: An array with links to other block logs
&$row: the revision row for this line
&$s: the string representing this parsed line
&$classes: array containing the <li> element classes
+&$attribs: associative array of other HTML attributes for the <li> element.
+ Currently only data attributes reserved to MediaWiki are allowed
+ (see Sanitizer::isReservedDataAttribute).
'PageHistoryPager::doBatchLookups': Called after the pager query was run, before
any output is generated, to allow batch lookups for prefetching information
&$pager: the pager
&$queryInfo: the query parameters
-'PageRenderingHash': Alter the parser cache option hash key. A parser extension
+'PageRenderingHash': NOTE: Consider using ParserOptionsRegister instead.
+Alter the parser cache option hash key. A parser extension
which depends on user options should install this hook and append its values to
the key.
&$confstr: reference to a hash key string which can be modified
&$params: 2-D array of parameters
$parser: Parser object that called the hook
+'ParserOptionsRegister': Register additional parser options. Note that if you
+change the default value for an option, all existing parser cache entries will
+be invalid. To avoid bugs, you'll need to handle that somehow (e.g. with the
+RejectParserCacheValue hook) because MediaWiki won't do it for you.
+&$defaults: Set the default value for your option here.
+&$inCacheKey: To fragment the parser cache on your option, set a truthy value here.
+&$lazyLoad: To lazy-initialize your option, set it null in $defaults and set a
+ callable here. The callable is passed the ParserOptions object and the option
+ name.
+
+'ParserOutputPostCacheTransform': Called from ParserOutput::getText() to do
+post-cache transforms.
+$parserOutput: The ParserOutput object.
+&$text: The text being transformed, before core transformations are done.
+&$options: The options array being used for the transformation.
+
'ParserSectionCreate': Called each time the parser creates a document section
from wikitext. Use this to apply per-section modifications to HTML (like
wrapping the section in a DIV). Caveat: DIVs are valid wikitext, and a DIV
$form: PreferencesForm object, also a ContextSource
$user: User object with preferences to be saved set
&$result: boolean indicating success
+$oldUserOptions: array with user old options (before save)
'PreferencesGetLegend': Override the text used for the <legend> of a
preferences section.
'RecentChange_save': Called at the end of RecentChange::save().
&$recentChange: RecentChange object
+'RecentChangesPurgeRows': Called when old recentchanges rows are purged, after
+deleting those rows but within the same transaction.
+$rows: The deleted rows as an array of recentchanges row objects (with up to
+ $wgUpdateRowsPerQuery items).
+
'RedirectSpecialArticleRedirectParams': Lets you alter the set of parameter
names such as "oldid" that are preserved when using redirecting special pages
such as Special:MyPage and Special:MyTalk.
or request state must be added through MakeGlobalVariablesScript instead.
&$vars: array( variable name => value )
-'ResourceLoaderGetLessVars': Called in ResourceLoader::getLessVars after
-variables from $wgResourceLoaderLESSVars are added. Can be used to add
-context-based variables.
+'ResourceLoaderGetLessVars': DEPRECATED! Called in ResourceLoader::getLessVars
+to add global LESS variables. Loaded after $wgResourceLoaderLESSVars is added.
+Global LESS variables are deprecated. Use ResourceLoaderModule::getLessVars()
+instead to expose variables only in modules that need them.
&$lessVars: array of variables already added
+'ResourceLoaderJqueryMsgModuleMagicWords': Called in
+ResourceLoaderJqueryMsgModule to allow adding magic words for jQueryMsg.
+The value should be a string, and they can depend only on the
+ResourceLoaderContext.
+$context: ResourceLoaderContext
+&$magicWords: Associative array mapping all-caps magic word to a string value
+
'ResourceLoaderRegisterModules': Right before modules information is required,
such as when responding to a resource
loader request or generating HTML output.
added to any module.
&$ResourceLoader: object
-'RevisionInsertComplete': Called after a revision is inserted into the database.
-&$revision: the Revision
-$data: the data stored in old_text. The meaning depends on $flags: if external
- is set, it's the URL of the revision text in external storage; otherwise,
- it's the revision text itself. In either case, if gzip is set, the revision
- text is gzipped.
-$flags: a comma-delimited list of strings representing the options used. May
- include: utf8 (this will always be set for new revisions); gzip; external.
+'RevisionRecordInserted': Called after a revision is inserted into the database.
+$revisionRecord: the RevisionRecord that has just been inserted.
+
+'RevisionInsertComplete': DEPRECATED! Use RevisionRecordInserted hook instead.
+Called after a revision is inserted into the database.
+$revision: the Revision
+$data: DEPRECATED! Always null!
+$flags: DEPRECATED! Always null!
'SearchableNamespaces': An option to modify which namespaces are searchable.
&$arr: Array of namespaces ($nsId => $name) which will be used.
$terms: String of the search terms entered
$specialSearch: The SpecialSearch object
&$query: Array of query string parameters for the link representing the search result.
+&$attributes: Array of title link attributes, can be modified by extension.
'SidebarBeforeOutput': Allows to edit sidebar just before it is output by skins.
Warning: This hook is run on each display. You should consider to use
&$item: HTML to be returned. Will be wrapped in <li></li> after the hook finishes
$row: Database row object
-'SpecialListusersHeader': Called before closing the <fieldset> in
+'SpecialListusersHeader': Called after adding the submit button in
UsersPager::getPageHeader().
$pager: The UsersPager instance
&$out: The header HTML
&$title: If the hook returns false, a Title object to use instead of the
result from the normal query
-'SpecialRecentChangesFilters': DEPRECATED! Use ChangesListSpecialPageFilters
+'SpecialRecentChangesFilters': DEPRECATED! Use ChangesListSpecialPageStructuredFilters
instead.
Called after building form options at RecentChanges.
$special: the special page object
&$extraOpts: array of added items, to which can be added
$opts: FormOptions for this request
-'SpecialRecentChangesQuery': DEPRECATED! Use ChangesListSpecialPageQuery
-instead.
+'SpecialRecentChangesQuery': DEPRECATED! Use ChangesListSpecialPageStructuredFilters
+or ChangesListSpecialPageQuery instead.
Called when building SQL query for SpecialRecentChanges and
SpecialRecentChangesLinked.
&$conds: array of WHERE conditionals for query
$title: The title the 'go' feature has decided to forward the user to
&$url: Initially null, hook subscribers can set this to specify the final url to redirect to
-'SpecialSearchNogomatch': Called when user clicked the "Go" button but the
-target doesn't exist.
+'SpecialSearchNogomatch': Called when the 'Go' feature is triggered (generally
+from autocomplete search other than the main bar on Special:Search) and the
+target doesn't exist. Full text search results are generated after this hook is
+called.
&$title: title object generated from the text entered by the user
'SpecialSearchPowerBox': The equivalent of SpecialSearchProfileForm for
$wgVersion: Current $wgVersion for you to use
&$versionUrl: Raw url to link to (eg: release notes)
-'SpecialWatchlistFilters': DEPRECATED! Use ChangesListSpecialPageFilters
+'SpecialWatchlistFilters': DEPRECATED! Use ChangesListSpecialPageStructuredFilters
instead.
Called after building form options at Watchlist.
$special: the special page object
inserted to rc_type so they can be returned as part of the watchlist.
&$nonRevisionTypes: array of values in the rc_type field of recentchanges table
-'SpecialWatchlistQuery': DEPRECATED! Use ChangesListSpecialPageQuery instead.
+'SpecialWatchlistQuery': DEPRECATED! Use ChangesListSpecialPageStructuredFilters
+or ChangesListSpecialPageQuery instead.
Called when building sql query for SpecialWatchlist.
&$conds: array of WHERE conditionals for query
&$tables: array of tables to be queried
$title: title object related to the revision
$rev: revision (object) that will be viewed
+'UnitTestsAfterDatabaseSetup': Called right after MediaWiki's test infrastructure
+has finished creating/duplicating core tables for unit tests.
+$database: Database in question
+$prefix: Table prefix to be used in unit tests
+
+'UnitTestsBeforeDatabaseTeardown': Called right before MediaWiki tears down its
+database infrastructure used for unit tests.
+
'UnitTestsList': Called when building a list of paths containing PHPUnit tests.
Since 1.24: Paths pointing to a directory will be recursively scanned for
test case files matching the suffix "Test.php".
instead.
&$form: UploadForm object
+'UploadForm:getInitialPageText': After the initial page text for file uploads
+is generated, to allow it to be altered.
+&$pageText: the page text
+$msg: array of header messages
+$config: Config object
+
'UploadForm:initial': Before the upload form is generated. You might set the
member-variables $uploadFormTextTop and $uploadFormTextAfterSummary to inject
text (HTML) either before or after the editform.
$performer: User who performed the change, false if via autopromotion
$reason: The reason, if any, given by the user performing the change,
false if via autopromotion.
+$oldUGMs: An associative array (group name => UserGroupMembership object) of
+the user's group memberships before the change.
+$newUGMs: An associative array (group name => UserGroupMembership object) of
+the user's current group memberships.
'UserIsBlockedFrom': Check if a user is blocked from a specific page (for
specific block exemptions).
$add: Array of strings corresponding to groups added
$remove: Array of strings corresponding to groups removed
-'UserSaveOptions': Called just before saving user preferences/options.
-$user: User object
-&$options: Options, modifiable
+'UserSaveOptions': Called just before saving user preferences. Hook handlers can either add or
+manipulate options, or reset one back to it's default to block changing it. Hook handlers are also
+allowed to abort the process by returning false, e.g. to save to a global profile instead. Compare
+to the UserSaveSettings hook, which is called after the preferences have been saved.
+$user: The User for which the options are going to be saved
+&$options: The users options as an associative array, modifiable
-'UserSaveSettings': Called when saving user settings.
-$user: User object
+'UserSaveSettings': Called directly after user preferences (user_properties in the database) have
+been saved. Compare to the UserSaveOptions hook, which is called before.
+$user: The User for which the options have been saved
'UserSetCookies': DEPRECATED! If you're trying to replace core session cookie
handling, you want to create a subclass of MediaWiki\Session\CookieSessionProvider
&$opts: Options to use for the query
&$join: Join conditions
-'WikiPageDeletionUpdates': manipulate the list of DataUpdates to be applied when
+'WikiPageDeletionUpdates': manipulate the list of DeferrableUpdates to be applied when
a page is deleted. Called in WikiPage::getDeletionUpdates(). Note that updates
specific to a content model should be provided by the respective Content's
getDeletionUpdates() method.
$page: the WikiPage
-$content: the Content to generate updates for (or null, if the Content could not be loaded
-due to an error)
-&$updates: the array of DataUpdate objects. Hook function may want to add to it.
+$content: the Content to generate updates for, or null in case the page revision could not be
+ loaded. The delete will succeed despite this.
+&$updates: the array of objects that implement DeferrableUpdate. Hook function may want to add to
+ it.
'WikiPageFactory': Override WikiPage class used for a title
$title: Title of the page