r97876 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r97875‎ | r97876 | r97877 >
Date:01:00, 23 September 2011
Author:preilly
Status:resolved (Comments)
Tags:
Comment:
fix for TestCanonicalRedirect hook
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.php
@@ -84,7 +84,7 @@
8585 }
8686
8787 class ExtMobileFrontend {
88 - const VERSION = '0.5.68';
 88+ const VERSION = '0.5.69';
8989
9090 /**
9191 * @var DOMDocument
@@ -200,9 +200,8 @@
201201 );
202202
203203 public function testCanonicalRedirect( $request, $title, $output ) {
204 - global $wgMobileDomain;
205 - $host = $request->getHeader( 'HOST' );
206 - return !( stristr( $host, $wgMobileDomain ) !== false );
 204+ $xDevice = isset( $_SERVER['HTTP_X_DEVICE'] ) ? $_SERVER['HTTP_X_DEVICE'] : '';
 205+ return ( !empty( $xDevice ) );
207206 }
208207
209208 public function addMobileFooter( &$obj, &$tpl ) {
@@ -216,7 +215,7 @@
217216 $footerlinks = $tpl->data['footerlinks'];
218217 $mobileViewUrl = $wgRequest->escapeAppendQuery( 'useformat=mobile' );
219218
220 - $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>".wfMsg( 'mobile-frontend-view')."</a>");
 219+ $tpl->set('mobileview', "<a href='{$mobileViewUrl}'>" . wfMsg( 'mobile-frontend-view' ) . "</a>");
221220 $footerlinks['places'][] = 'mobileview';
222221 $tpl->set('footerlinks', $footerlinks);
223222 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r97877fix for TestCanonicalRedirect hookpreilly01:01, 23 September 2011
r97878fix for TestCanonicalRedirect hookpreilly01:06, 23 September 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r97645fix for bug 31012 - mobile version replaced by desktop version in a webview o...preilly17:21, 20 September 2011

Comments

#Comment by Brion VIBBER (talk | contribs)   01:04, 23 September 2011

This switches the redirect detection avoidance for bug 31012 (r97645) from checking the hostname (which it turns out we're pretty sure doesn't actually get reported as the 'm.' form once it gets through the proxies) to checking for an HTTP X-Device header, which the proxies set for us on the 'm.' domain. This should make the fix check match the checks used for display.

#Comment by Brion VIBBER (talk | contribs)   01:05, 23 September 2011

Damn good thing we're both looking at this -- condition was reversed. :) resolved in r97877 -- suggested a more explicit form so we don't mess it up again, about to be committed.

Status & tagging log