Add in a 'TestCanonicalRedirect' hook to be called when about to make a redirect...
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 19 Sep 2011 23:14:52 +0000 (23:14 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 19 Sep 2011 23:14:52 +0000 (23:14 +0000)
Support for resolving bug 31012.

docs/hooks.txt
includes/Wiki.php

index 5f3a7da..536ee8f 100644 (file)
@@ -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
index a0d7751..74e93d1 100644 (file)
@@ -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() );