http://www.mediawiki.org/wiki/Special:Code/MediaWiki/97573

Revision: 97573
Author:   brion
Date:     2011-09-19 23:14:52 +0000 (Mon, 19 Sep 2011)
Log Message:
-----------
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.

Modified Paths:
--------------
    trunk/phase3/docs/hooks.txt
    trunk/phase3/includes/Wiki.php

Modified: trunk/phase3/docs/hooks.txt
===================================================================
--- trunk/phase3/docs/hooks.txt 2011-09-19 23:11:54 UTC (rev 97572)
+++ trunk/phase3/docs/hooks.txt 2011-09-19 23:14:52 UTC (rev 97573)
@@ -1823,6 +1823,11 @@
 &$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

Modified: trunk/phase3/includes/Wiki.php
===================================================================
--- trunk/phase3/includes/Wiki.php      2011-09-19 23:11:54 UTC (rev 97572)
+++ trunk/phase3/includes/Wiki.php      2011-09-19 23:14:52 UTC (rev 97573)
@@ -180,7 +180,8 @@
                } 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() );


_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to