Last modified: 2014-11-18 01:12:24 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T56885, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 54885 - MobileFrontend doesn't remember user choice (mobile/desktop) in some use cases
MobileFrontend doesn't remember user choice (mobile/desktop) in some use cases
Status: UNCONFIRMED
Product: MobileFrontend
Classification: Unclassified
stable (Other open bugs)
unspecified
All All
: Unprioritized trivial
: ---
Assigned To: Kelson [Emmanuel Engelhart]
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2013-10-02 16:47 UTC by Kelson [Emmanuel Engelhart]
Modified: 2014-11-18 01:12 UTC (History)
13 users (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Kelson [Emmanuel Engelhart] 2013-10-02 16:47:10 UTC
With a tablet, each time I load a page I have to click on "desktop view" because the "mobile view" is always loaded, this independently of previous choices.

Conf:
$wgMFAutodetectMobileView = true;
$wgMobileFrontendFormatCookieExpiry = 4200000000;

MW 1.21.2 + last stable release of the extension.
Comment 1 Bingle 2013-10-02 16:48:21 UTC
Prioritization and scheduling of this bug is tracked on Mingle card https://wikimedia.mingle.thoughtworks.com/projects/mobile/cards/1277
Comment 2 Jon 2013-10-02 16:57:21 UTC
Do you have cookies enabled on that browser?
Comment 3 Kelson [Emmanuel Engelhart] 2013-10-02 17:04:47 UTC
yes, cookie is activated on my Firefox (android edition)
Comment 4 Arthur Richards 2013-10-08 22:12:40 UTC
Kelson, I'm unable to replicate the problem you describe. Can you provide some additional information:

* When you say 'last stable release of the extension' what exactly do you mean? We do not package specific releases of the extension. Perhaps you can provide the sha1 of git checkout? (Note that current master of MobileFrontend will *not* work with Mediawiki 1.21.2)
* What kind of table are you using? Or better yet, can you provide the User-Agent of your browser?
* Is it possible for you to verify whether or not you get a cookie named 'stopMobileRedirect' set after tapping 'desktop view'?
* Can you describe the architecture you're using to run MobileFrontend and in particular if you're using any kind of caching service like Squid or Varnish.
Comment 5 Kelson [Emmanuel Engelhart] 2013-10-09 08:35:35 UTC
@Arthur
Thank you for your comment. Give me please a little bit time to lead this investigation and deliver the results here.
Comment 6 Arthur Richards 2013-10-29 17:22:11 UTC
Marking as WORKSFORME until someone else can confirm the issue.
Comment 7 Kelson [Emmanuel Engelhart] 2014-02-01 18:24:50 UTC
I have investigated a little bit and the problem is related to the "stopMobileRedirect" cookie.
The reaon is that the domain is wrong in with "exotic" setups (so the cookie does not apply).

For example if:
* The server name has more than 3 parts (like wiki.wikimedia.org.uk) and you don't have setup $wgMFStopRedirectCookieHost.
* You access the server under an other address like specified in $wgMFStopRedirectCookieHost

In a try to fix this I can propose following changes to MobileContext.php.
$ diff MobileContext.php.back MobileContext.php
473,477c473
< 			$domainParts = explode( '.', $host );
< 			$domainParts = array_reverse( $domainParts );
< 			// Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included.
< 			wfProfileOut( __METHOD__ );
< 			return count( $domainParts ) >= 2 ? '.' . $domainParts[1] . '.' . $domainParts[0] : $host;
---
>                         return substr( $host, strpos( $host, "." ) );
493c489
< 		if ( !$wgMFStopRedirectCookieHost ) {
---
> 		if ( !$wgMFStopRedirectCookieHost || $wgMFStopRedirectCookieHost != $this->getRequest()->getHeader( 'Host' ) ) {
Comment 8 Kelson [Emmanuel Engelhart] 2014-02-01 19:24:08 UTC
My previous patch does not fix the whole problem. If you have your wiki available at http://wikimedia.org.uk, the computed domain name will be ".org.uk". ".org.uk" is not accepted by Firefox (and probably other browsers) because this is a top level domain.

To fix this, I don't see any other solution than introducing a new configuration variable called $wgMFCookieDomain. Here would be the new patch.

$ diff MobileContext.php.back MobileContext.php
473,477c473
< 			$domainParts = explode( '.', $host );
< 			$domainParts = array_reverse( $domainParts );
< 			// Although some browsers will accept cookies without the initial ., » RFC 2109 requires it to be included.
< 			wfProfileOut( __METHOD__ );
< 			return count( $domainParts ) >= 2 ? '.' . $domainParts[1] . '.' . $domainParts[0] : $host;
---
>                         return substr( $host, strpos( $host, "." ) );
491c487,488
< 		global $wgMFStopRedirectCookieHost;
---
> 		global $wgMFStopRedirectCookieHost, $wgMFCookieDomain;
> 		$host = $this->getRequest()->getHeader( 'Host' );
493,494c490,495
< 		if ( !$wgMFStopRedirectCookieHost ) {
< 			$wgMFStopRedirectCookieHost = $this->getBaseDomain();
---
> 		if ( !$wgMFStopRedirectCookieHost || $wgMFStopRedirectCookieHost != $host ) {
> 		        if ( $wgMFCookieDomain && ( strpos( $host, $wgMFCookieDomain ) !== false )) {
> 			  $wgMFStopRedirectCookieHost = $wgMFCookieDomain;
> 			} else {
> 			  $wgMFStopRedirectCookieHost = $this->getBaseDomain();
> 			}
Comment 9 Arthur Richards 2014-02-03 22:42:12 UTC
Kelson, thanks for digging deeper and following up. Will you submit your patch to gerrit?
Comment 10 Arthur Richards 2014-02-27 22:37:00 UTC
Kelson, just wanted to poke again - can you please submit your patch to gerrit? It will be easier to review, test, and make comments on it there.
Comment 11 Andre Klapper 2014-02-28 10:52:40 UTC
If the patch was added as an attachment here one could use Valhallsw's script to upload it via http://tools.wmflabs.org/gerrit-patch-uploader/ ...
Comment 12 Kelson [Emmanuel Engelhart] 2014-02-28 11:48:50 UTC
Will do it, I don't have forgotten...
Comment 13 Kelson [Emmanuel Engelhart] 2014-03-09 19:01:52 UTC
Hmmm, it seems I have failed to attach the commit to the bug :(
https://integration.wikimedia.org/ci/job/mwext-MobileFrontend-lint/8982/console
Comment 14 Kelson [Emmanuel Engelhart] 2014-03-09 19:02:20 UTC
https://gerrit.wikimedia.org/r/#/c/117699/
Comment 15 Gerrit Notification Bot 2014-03-11 00:00:56 UTC
Change 117699 had a related patch set uploaded by Jdlrobson:
Remember user choice (mobile/desktop)

https://gerrit.wikimedia.org/r/117699
Comment 16 Gerrit Notification Bot 2014-06-16 19:25:29 UTC
Change 117699 abandoned by Jdlrobson:
Remember user choice (mobile/desktop)

Reason:
Abandoning to clear the code review queue due to lack of activity. Please re-submit it when you have the time. Thanks!

https://gerrit.wikimedia.org/r/117699
Comment 17 Derk-Jan Hartman 2014-07-02 14:20:35 UTC
also, when on https, the stopMobileRedirect cookie is set with the 'secure' flag on. That means it won't be visible if the user enters from an http:// url from google for instance...

Is this intentional ?
Comment 18 Jon 2014-10-09 17:26:55 UTC
What is the status of this bug now?
Comment 19 Bingle 2014-10-09 17:30:17 UTC
Prioritization and scheduling of this bug is tracked on Trello card https://trello.com/c/gtF11D1B
Comment 20 Kelson [Emmanuel Engelhart] 2014-10-09 18:56:33 UTC
Thank you Jon for your patience. I just failed to give enough time to provide a correct patch here (I'm not so familiar with the whole testing infrastructure).

It works for the WMUK instance and this is the most important to me.

But it still on my TODO list... or someone else will do the patch as the bug/patch relatively trivial is.
Comment 21 Sam Smith 2014-11-05 11:30:14 UTC
(In reply to Derk-Jan Hartman from comment #17)
> also, when on https, the stopMobileRedirect cookie is set with the 'secure'
> flag on. That means it won't be visible if the user enters from an http://
> url from google for instance...
> 
> Is this intentional ?

This was fixed as part of bug 68347.
Comment 22 Sam Smith 2014-11-05 11:54:55 UTC
Kelson,

This bug has been added to the Mobile Web team's current sprint (see https://trello.com/c/gtF11D1B) and I'm taking a look.

I've read through the patch that Jon submitted on your behalf and it looks okay. However, I'm wondering what you had/have the wgMFStopMobileRedirect configuration variable set to. I ask because that variable seems to be used to override MobileContext#getBaseDomain in #getStopMobileRedirectCookieDomain.
Comment 23 Sam Smith 2014-11-05 15:18:04 UTC
Sorry, wgMFStopRedirectCookieHost.
Comment 24 Kelson [Emmanuel Engelhart] 2014-11-14 17:11:53 UTC
@Sam

Thank you for trying to push this bug/patch. I have explained in 
https://bugzilla.wikimedia.org/show_bug.cgi?id=54885#c8 why I had to create this new configuration value.
Comment 25 Sam Smith 2014-11-14 20:41:54 UTC
No problem Kelson.

MobileContext#getStopMobileRedirectCookieDomain returns wgMFStopRedirectCookieHost when it's defined. So why not set wgMFStopRedirectCookieHost to '.wikimedia.org.uk', rather than create another mechanism for setting the cookie domain?
Comment 26 Jon 2014-11-18 01:12:24 UTC
Marking as unconfirmed until we hear back from Kelson.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links