Jump to navigation Jump to search
Available from version 1.4.0
Removed in version 1.32.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.


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

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.

This hook is deprecated since MediaWiki version 1.19. Instead of using this hook, extensions should add their actions to $wgActions.


  • $action: action name
  • $article: article "acted on" - this is a Page object, not the article name.

See also[edit]