r97645 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97644‎ | r97645 | r97646 >
Date:17:21, 20 September 2011
Author:preilly
Status:ok (Comments)
Tags:
Comment:
fix for bug 31012 - mobile version replaced by desktop version in a webview on iPad apps
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -49,6 +49,7 @@
5050 */
5151 $wgMobileFrontendLogo = false;
5252
 53+$wgMobileDomain = '.m.';
5354
5455 $wgExtMobileFrontend = new ExtMobileFrontend();
5556
@@ -57,6 +58,8 @@
5859 $wgHooks['SkinTemplateOutputPageBeforeExec'][] = array( &$wgExtMobileFrontend, 'addMobileFooter' );
5960 $wgExtensionFunctions[] = array( &$wgExtMobileFrontend, 'setDefaultLogo' );
6061
 62+$wgHooks['TestCanonicalRedirect'][] = array( &$wgExtMobileFrontend, 'testCanonicalRedirect' );
 63+
6164 /**
6265 * Make the classes stripped from page content configurable. Each item will
6366 * be stripped from the page. See $itemsToRemove for more info
@@ -73,7 +76,7 @@
7477 }
7578
7679 class ExtMobileFrontend {
77 - const VERSION = '0.5.64';
 80+ const VERSION = '0.5.65';
7881
7982 /**
8083 * @var DOMDocument
@@ -186,6 +189,12 @@
187190 '#ogg_player_1',
188191 '.nomobile',
189192 );
 193+
 194+ public function testCanonicalRedirect( $request, $title, $output ) {
 195+ global $wgMobileDomain;
 196+ $host = $request->getHeader( 'HOST' );
 197+ return ( stristr( $host, $wgMobileDomain ) !== false ) ? false : true;
 198+ }
190199
191200 public function addMobileFooter( &$obj, &$tpl ) {
192201 global $wgRequest;

Follow-up revisions

RevisionCommit summaryAuthorDate
r97748fix for r97645 comment 22929preilly17:23, 21 September 2011
r97876fix for TestCanonicalRedirect hookpreilly01:00, 23 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97573Add in a 'TestCanonicalRedirect' hook to be called when about to make a redir...brion23:14, 19 September 2011
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

Comments

#Comment by 😂 (talk | contribs)   14:34, 21 September 2011

Using ternary for false/true is kind of silly :) Just do this instead:

!( stristr( $host, $wgMobileDomain ) !== false )
#Comment by Preilly (talk | contribs)   17:24, 21 September 2011

This should now be fixed in r97748.

#Comment by Brion VIBBER (talk | contribs)   21:21, 21 September 2011

Marking this ok -- it worked in our local tests at least, though this isn't the most ideal solution ever.

Status & tagging log