r97573 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97572‎ | r97573 | r97574 >
Date:23:14, 19 September 2011
Author:brion
Status:ok (Comments)
Tags:
Comment:
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 (modified) (history)
  • /trunk/phase3/includes/Wiki.php (modified) (history)

Diff [purge]

Index: trunk/phase3/docs/hooks.txt
@@ -1823,6 +1823,11 @@
18241824 &$join_conds: join conditions for the tables
18251825 &$fields: array of query fields
18261826
 1827+'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.
 1828+$request: WebRequest
 1829+$title: Title of the currently found title obj
 1830+$output: OutputPage object
 1831+
18271832 'TitleArrayFromResult': called when creating an TitleArray object from a
18281833 database result
18291834 &$titleArray: set this to an object to override the default object returned
Index: trunk/phase3/includes/Wiki.php
@@ -180,7 +180,8 @@
181181 } elseif ( $request->getVal( 'action', 'view' ) == 'view' && !$request->wasPosted()
182182 && ( $request->getVal( 'title' ) === null ||
183183 $title->getPrefixedDBKey() != $request->getVal( 'title' ) )
184 - && !count( $request->getValueNames( array( 'action', 'title' ) ) ) )
 184+ && !count( $request->getValueNames( array( 'action', 'title' ) ) )
 185+ && wfRunHooks( 'TestCanonicalRedirect', array( $request, $title, $output ) ) )
185186 {
186187 if ( $title->getNamespace() == NS_SPECIAL ) {
187188 list( $name, $subpage ) = SpecialPageFactory::resolveAlias( $title->getDBkey() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r97574MFT r97573 - hook to help with bug 31012 on MobileFrontend & similarbrion23:23, 19 September 2011
r97576MFT r97573 - hook to help with bug 31012 on MobileFrontend & similarbrion23:25, 19 September 2011
r97580MFT r97573 - hook to help with bug 31012 on MobileFrontend & similarbrion23:51, 19 September 2011
r97645fix for bug 31012 - mobile version replaced by desktop version in a webview o...preilly17:21, 20 September 2011

Comments

#Comment by RobLa-WMF (talk | contribs)   23:45, 19 September 2011

You may also need to merge this into 118wmf1 to ensure this makes it out into production for 1.18

#Comment by Brion VIBBER (talk | contribs)   23:51, 19 September 2011

There's always another branch! ;) Done.

Status & tagging log