Jdlrobson has submitted this change and it was merged.
Change subject: Do not display desktop view on mobile domain
......................................................................
Do not display desktop view on mobile domain
I initially attempted to do this a less hacky way by attempting to more
accurately determine whether or not a user was on a mobile-specific
domain, but unfortunately it was an untennable solution since $wgServer
will always evaluate to the desktop domain. This solution should work,
although it will cause problems if there is a separate desktop and
mobile domain, X-Device gets set by proxy or webserver that handles desktop
domain, and the user attempts to access desktop domain. This seems like
an unlikely scenario (why would you ever set X-Device for a desktop-only
domain?). Also, I would've liked to have added tests for this, but
unfortunately there's no reasonable way to handle cookies in phpunit :(
Bug: 46473
Change-Id: I56f2c8a2626042bf7b9a1d94fbf14ec8e2f089c5
---
M includes/MobileContext.php
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
Jdlrobson: Verified; Looks good to me, approved
diff --git a/includes/MobileContext.php b/includes/MobileContext.php
index d598994..ff13114 100644
--- a/includes/MobileContext.php
+++ b/includes/MobileContext.php
@@ -238,6 +238,7 @@
* @return bool Value for shouldDisplayMobileView()
*/
private function shouldDisplayMobileViewInternal() {
+ global $wgMobileUrlTemplate;
// always display non-mobile view for edit/history/diff
$action = $this->getAction();
$req = $this->getRequest();
@@ -265,6 +266,19 @@
return true;
}
+ /**
+ * If a mobile-domain is specified by the $wgMobileUrlTemplate
and
+ * there's an X-Device header, then we assume the user is
accessing
+ * the site from the mobile-specific domain (because why would
the
+ * desktop site set X-Device header?). If a user is accessing
the
+ * site from a mobile domain, then we should always display the
mobile
+ * version of the site (otherwise, the cache may get polluted).
See
+ * https://bugzilla.wikimedia.org/show_bug.cgi?id=46473
+ */
+ if ( $wgMobileUrlTemplate && $this->getXDevice() ) {
+ return true;
+ }
+
// check cookies for what to display
$useMobileFormat = $this->getUseFormatCookie();
if ( $useMobileFormat == 'true' ) {
--
To view, visit https://gerrit.wikimedia.org/r/59778
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I56f2c8a2626042bf7b9a1d94fbf14ec8e2f089c5
Gerrit-PatchSet: 4
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: awjrichards <[email protected]>
Gerrit-Reviewer: Jdlrobson <[email protected]>
Gerrit-Reviewer: MaxSem <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits