Manual:Hooks/UnknownAction
![]() | This deprecated feature should no longer be used, but is still available for reasons of backwards compatibility.
This feature was deprecated in version 1.19. Instead of using this hook, add your actions to $wgActions . |
UnknownAction | |
---|---|
Available from version 1.4.0 Used to add new query-string actions | |
Define function: |
public static function onUnknownAction( $action, Article $article ) { ... }
|
Attach hook: |
In extension.json: {
"Hooks": {
"UnknownAction": "MyExtensionHooks::onUnknownAction"
}
}
For MediaWiki ≤1.25: $wgHooks['UnknownAction'][] = 'MyExtensionHooks::onUnknownAction';
|
Called from: | File(s): MediaWiki.php |
For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:UnknownAction extensions.
Details[edit]
Actions for a page are passed to MediaWiki via the action parameter in the URL. For example, to edit the page 'Foo' the action edit
would be appended to the main article URL, giving http://www.mywiki.org/wiki/index.php?title=Foo&action=edit
.
This hook allows you to add custom actions to MediaWiki. If an action is requested that the software doesn't handle natively, this hook will be called.
Returning false will allow processing to continue, but it will not output any content for the page. You will need to use $wgOut->addWikiText(...);
and similar functions to create the appropriate page content for this action, and $wgOut->setPageTitle(...);
to set the title for display at the top of the page.
Returning true will cause the standard 'no such action' message that you get when entering &action=nonexistant_action.
$wgActions
.Arguments[edit]
- $action: action name
- $article: article "acted on" - this is a Page object, not the article name.
See also[edit]
$wgActions
- MediaWikiPerformAction hook - used before default actions are called, used for overriding normal processes (ie: alternate action=edit, action=watch)