Awjrichards has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/116180

Change subject: Ensure checkToggleView() fires at appropriate time
......................................................................

Ensure checkToggleView() fires at appropriate time

Resolves bug 61400. MobileContext::checkToggleView() was firing after
the first time shouldDisplayMobileView() did, rendering it partly
impotent. Now it will fire just before
shouldDisplayMobileViewInternal(), ensuring it is properly honored.

Also removes shouldDisplayMobileView() check prior to running
GetMobileUrl hook. shouldDisplayMobileView() should not get called from
getMobileUrl() (with this patch, it can cause an infinite loop), but
getMobileUrl() shoudl not care whether or not we are in mobile mode.
Bug: 61400

Change-Id: Ic94dbd73634edcd2dd35065c1e7f7a0ca03340dd
---
M includes/MobileContext.php
M includes/MobileFrontend.hooks.php
2 files changed, 9 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/80/116180/1

diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index dd18351..ed697a6 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -274,6 +274,8 @@
                        return $this->mobileView;
                }
                wfProfileIn( __METHOD__ );
+               // check if the user requested to toggle their view 
+               $this->checkToggleView();
                $this->mobileView = $this->shouldDisplayMobileViewInternal();
                if ( $this->mobileView ) {
                        $this->redirectMobileEnabledPages();
@@ -610,15 +612,13 @@
         */
        public function getMobileUrl( $url, $forceHttps = false ) {
 
-               if ( $this->shouldDisplayMobileView() ) {
-                       $subdomainTokenReplacement = null;
-                       if ( wfRunHooks( 'GetMobileUrl', array( 
&$subdomainTokenReplacement, $this ) ) ) {
-                               if ( !empty( $subdomainTokenReplacement ) ) {
-                                       global $wgMobileUrlTemplate;
-                                       $mobileUrlHostTemplate = 
$this->parseMobileUrlTemplate( 'host' );
-                                       $mobileToken = 
$this->getMobileHostToken( $mobileUrlHostTemplate );
-                                       $wgMobileUrlTemplate = str_replace( 
$mobileToken, $subdomainTokenReplacement, $wgMobileUrlTemplate );
-                               }
+               $subdomainTokenReplacement = null;
+               if ( wfRunHooks( 'GetMobileUrl', array( 
&$subdomainTokenReplacement, $this ) ) ) {
+                       if ( !empty( $subdomainTokenReplacement ) ) {
+                               global $wgMobileUrlTemplate;
+                               $mobileUrlHostTemplate = 
$this->parseMobileUrlTemplate( 'host' );
+                               $mobileToken = $this->getMobileHostToken( 
$mobileUrlHostTemplate );
+                               $wgMobileUrlTemplate = str_replace( 
$mobileToken, $subdomainTokenReplacement, $wgMobileUrlTemplate );
                        }
                }
 
diff --git a/includes/MobileFrontend.hooks.php 
b/includes/MobileFrontend.hooks.php
index 6f39918..5aef038 100644
--- a/includes/MobileFrontend.hooks.php
+++ b/includes/MobileFrontend.hooks.php
@@ -44,9 +44,7 @@
                global $wgMFEnableDesktopResources, $wgMFDefaultSkinClass, 
$wgULSPosition,
                        $wgMFWap, $wgValidSkinNames, 
$wgMFEnableMinervaBetaFeature;
 
-               // check whether or not the user has requested to toggle their 
view
                $mobileContext = MobileContext::singleton();
-               $mobileContext->checkToggleView();
 
                if ( !$mobileContext->shouldDisplayMobileView()
                        || $mobileContext->isBlacklistedPage()

-- 
To view, visit https://gerrit.wikimedia.org/r/116180
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic94dbd73634edcd2dd35065c1e7f7a0ca03340dd
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Awjrichards <aricha...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to