https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114409

Revision: 114409
Author:   awjrichards
Date:     2012-03-21 21:36:05 +0000 (Wed, 21 Mar 2012)
Log Message:
-----------
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: trunk/extensions/MobileFrontend/MobileFrontend.body.php
===================================================================
--- trunk/extensions/MobileFrontend/MobileFrontend.body.php     2012-03-21 
21:28:09 UTC (rev 114408)
+++ trunk/extensions/MobileFrontend/MobileFrontend.body.php     2012-03-21 
21:36:05 UTC (rev 114409)
@@ -1457,7 +1457,7 @@
        }
        
        public function checkUseFormatCookie() {
-               global $wgRequest, $wgCookiePrefix;
+               global $wgRequest, $wgCookiePrefix, $wgScriptPath;
                
                if ( !isset( self::$useFormatCookieName )) {
                        self::$useFormatCookieName = $wgCookiePrefix . 
'mf_useformat';
@@ -1471,9 +1471,15 @@
                        $this->setUseFormat( $useFormatFromCookie );
                }
                
-               // set appropriate cookie if necessary
-               if ( ( $useFormatFromCookie != 'mobile' && $useFormat == 
'mobile' ) ||
-                               ( $useFormatFromCookie != 'desktop' && 
$useFormat == 'desktop' ) ) {
+               // set appropriate cookie if necessary, ignoring certain URL 
patterns
+               // eg initial requests to a mobile-specific domain with no 
path. this 
+               // is intended to avoid pitfalls for certain server 
configurations
+               // but should not get in the way of out-of-the-box configs
+               $reqUrl = $wgRequest->getRequestUrl();
+               $urlsToIgnore = array( '/?useformat=mobile', $wgScriptPath . 
'/?useformat=mobile' );
+               if ( ( ( $useFormatFromCookie != 'mobile' && $useFormat == 
'mobile' ) ||
+                               ( $useFormatFromCookie != 'desktop' && 
$useFormat == 'desktop' ) ) &&
+                               !in_array( $reqUrl, $urlsToIgnore ) ) {
                        $this->setUseFormatCookie( $useFormat );
                }
        }


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

Reply via email to