Manual:Hooks/TestCanonicalRedirect

From MediaWiki.org
Jump to navigation Jump to search
TestCanonicalRedirect
Available from version 1.18.0 (r97573)
Called when about to force a redirect to a canonical URL for a title when we have no other parameters on the URL.
Define function:
public static function onTestCanonicalRedirect( $request, $title, $output ) { ... }
Attach hook:

In extension.json:

{
	"Hooks": {
		"TestCanonicalRedirect": "MyExtensionHooks::onTestCanonicalRedirect"
	}
}

For MediaWiki ≤1.25:

$wgHooks['TestCanonicalRedirect'][] = 'MyExtensionHooks::onTestCanonicalRedirect';
Called from: File(s): MediaWiki.php

For more information about attaching hooks, see Manual:Hooks.
For examples of extensions using this hook, see Category:TestCanonicalRedirect extensions.

Details[edit]

Gives a chance for extensions that alter page view behavior radically to abort that redirect or handle it manually.

  • $request: WebRequest
  • $title: Title of the currently found title obj
  • $output: OutputPage object