From 7da1d55a84ada91e144dd71675f368826bc7590b Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 19 Sep 2011 23:14:52 +0000 Subject: [PATCH] Add in a 'TestCanonicalRedirect' hook to be called when about to make a redirect to the canonical page form of a regular page view. Some extensions such as MobileProfile may need to modify this logic to prevent incorrect redirects, such as on alternate en.m.wikipedia.org domain, where we'd want to either skip it or rewrite to the alternate domain. Support for resolving bug 31012. --- docs/hooks.txt | 5 +++++ includes/Wiki.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/hooks.txt b/docs/hooks.txt index 5f3a7da451..536ee8f416 100644 --- a/docs/hooks.txt +++ b/docs/hooks.txt @@ -1823,6 +1823,11 @@ Each key maps to an associative array with a 'msg' (message key) and a 'default' &$join_conds: join conditions for the tables &$fields: array of query fields +'TestCanonicalRedirect': called when about to force a redirect to a canonical URL for a title when we have no other parameters on the URL. 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 + 'TitleArrayFromResult': called when creating an TitleArray object from a database result &$titleArray: set this to an object to override the default object returned diff --git a/includes/Wiki.php b/includes/Wiki.php index a0d7751a5b..74e93d18f2 100644 --- a/includes/Wiki.php +++ b/includes/Wiki.php @@ -180,7 +180,8 @@ class MediaWiki { } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted() && ( $request->getVal( 'title' ) === null || $title->getPrefixedDBKey() != $request->getVal( 'title' ) ) - && !count( $request->getValueNames( array( 'action', 'title' ) ) ) ) + && !count( $request->getValueNames( array( 'action', 'title' ) ) ) + && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) ) { if ( $title->getNamespace() == NS_SPECIAL ) { list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() ); -- 2.20.1