r114409 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114408‎ | r114409 | r114410 >
Date:21:36, 21 March 2012
Author:awjrichards
Status:ok
Tags:
Comment:
No longer setting useformat cookie if URL = "/?useformat=mobile" or "$wgScriptPath/?useformat=mobile" to avoid some pitfalls with certain server setups including WMF, where if varnish sees a "/" URL, it will append ?useformat=mobile to ensure proper handling of the mobile site + home page. This case should only happen in the event the user is following an external link or typing in the (mobile) URL themselves and does not represent an election for the "mobile view" in the same wasy as clicking on the "mobile view" link and should not be considered as such.
Modified paths:
  • /trunk/extensions/MobileFrontend/MobileFrontend.body.php (modified) (history)

Diff [purge]

Index: trunk/extensions/MobileFrontend/MobileFrontend.body.php
@@ -1457,7 +1457,7 @@
14581458 }
14591459
14601460 public function checkUseFormatCookie() {
1461 - global $wgRequest, $wgCookiePrefix;
 1461+ global $wgRequest, $wgCookiePrefix, $wgScriptPath;
14621462
14631463 if ( !isset( self::$useFormatCookieName )) {
14641464 self::$useFormatCookieName = $wgCookiePrefix . 'mf_useformat';
@@ -1471,9 +1471,15 @@
14721472 $this->setUseFormat( $useFormatFromCookie );
14731473 }
14741474
1475 - // set appropriate cookie if necessary
1476 - if ( ( $useFormatFromCookie != 'mobile' && $useFormat == 'mobile' ) ||
1477 - ( $useFormatFromCookie != 'desktop' && $useFormat == 'desktop' ) ) {
 1475+ // set appropriate cookie if necessary, ignoring certain URL patterns
 1476+ // eg initial requests to a mobile-specific domain with no path. this
 1477+ // is intended to avoid pitfalls for certain server configurations
 1478+ // but should not get in the way of out-of-the-box configs
 1479+ $reqUrl = $wgRequest->getRequestUrl();
 1480+ $urlsToIgnore = array( '/?useformat=mobile', $wgScriptPath . '/?useformat=mobile' );
 1481+ if ( ( ( $useFormatFromCookie != 'mobile' && $useFormat == 'mobile' ) ||
 1482+ ( $useFormatFromCookie != 'desktop' && $useFormat == 'desktop' ) ) &&
 1483+ !in_array( $reqUrl, $urlsToIgnore ) ) {
14781484 $this->setUseFormatCookie( $useFormat );
14791485 }
14801486 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r114413MFT r114409awjrichards21:51, 21 March 2012

Status & tagging log