Page MenuHomePhabricator

AMC Outreach Drawer encouraging me to turn on advanced mode sends me from Special:Homepage to my user page
Closed, ResolvedPublic

Description

I visited Special:Homepage on mobile beta labs and got a popup encouraging me to enable advanced mode. When I agreed, it reloaded the page in advanced mode, but it sent me to my user page instead of Special:Homepage. (Perhaps this is because we set the relevantTitle of Special:Homepage to the user page?)

Steps to reproduce

  1. Open a new incognito window,
  2. Login to https://en.m.wikipedia.beta.wmflabs.org/wiki/Special:Homepage as a user with AMC disabled
  3. When the outreach drawer appears, click the "Enable advanced mode" button
  4. Notice that you are redirected to the user page instead of back to Special:Homepage

Expected results

  • User is redirected back to the page they enabled AMC from (in this case Special:Homepage)

Actual results

  • User is redirected to user page

Dev notes

The amc outreach form uses currentPage.js to determine an appropriate redirection. currentPage.js [[ https://github.com/wikimedia/mediawiki-extensions-MobileFrontend/blob/b16895f9483c5949cd18d8b3f8400245f9b1952b/src/mobile.startup/currentPage.js#L25 | uses wgRelevantPageName ]] to determine the current page's title:

mw.Title.newFromText( mw.config.get( 'wgRelevantPageName' ) );

Pages like Special:Homepage and Special:WhatLinksHere can set [[ https://www.mediawiki.org/wiki/Manual:Interface/JavaScript | wgRelevantPageName ]] to something other than the current page's title, however which is why this bug is occurring.

Possible solutions

  1. Use [[ https://www.mediawiki.org/wiki/Manual:Interface/JavaScript | wgPageName ]] instead of wgRelevantPageName to determine the page to redirect back to. This is what https://gerrit.wikimedia.org/r/531743 attempts to do. This might be simplest solution, however if the user lands on a page with other query params (besides title), these would get dropped upon redirection. We could add another query param returntoquery to prevent this from happening which is what the login link does, but this will probably require some messy/unfun finagling of query params.
  1. Use the entire relative path to determine what page to redirect to. This is what https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/531588/ attempts to do, but it seems that using returnto/returntoquery is the popular way to handle this within the mediawiki ecosystem
  1. Use an ajax request to perform the POST and then refresh the page once successful. However, we would probably have to show a spinner while the request is performed and may have to handle any error messages from the backend. I also think a spinner followed by a full page refresh can be a little jarring to the user.

QA Results

ACStatusDetails
1T230927#5468134

Event Timeline

Jdlrobson added subscribers: Esanders, Jdlrobson.

The form is creating a link to the user page "/w/index.php?title=Special:MobileOptions&returnto=User%3AJdlrobson"

This is using:

mw.mobileFrontend.require('mobile.startup').currentPage()

which does indeed use wgRelevantPageName:

mw.Title.newFromText( mw.config.get( 'wgRelevantPageName' ) );

@Catrope I'm not sure what the reason for using wgRelevantPageName was there but is there a strong reason Special:MobileHomepage sets wgRelevantName ? Is the code above wrong or is Special:HomePage wrong?

wgRelevantPageName was added in T217826 by @Esanders in https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/494907/

I did some testing of the outreach drawer on the Special:WhatLinksHere page (e.g. http://localhost:8181/w/index.php?title=Special%3AWhatLinksHere&target=Test&namespace=) which https://gerrit.wikimedia.org/r/#/c/mediawiki/extensions/MobileFrontend/+/494907/ cites as the reason to use wgRelevantPageName, but it seems that wgRelevantPageName points to the actual article instead of back to the 'Special:WhatLinksHere' page in this scenario so there is buggy behavior on this page as well.

Additionally, even if we used wgPageName instead of wgRelevantPageName, the query params would still be dropped and the user would be redirected back to the plan Special:WhatLinksHere page once they enabled AMC through the form.

Now, I'm wondering if the form should just be using an absolute url for the returnto query param to account for these cases and if using wgPageName/wgRelevantPageName is futile.

Change 531588 had a related patch set uploaded (by Nray; owner: Nray):
[mediawiki/extensions/MobileFrontend@master] 🐛 Fix Amc Outreach Drawer Redirection

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

nray renamed this task from Popup encouraging me to turn on advanced mode sends me from Special:Homepage to my user page to AMC Outreach Drawer encouraging me to turn on advanced mode sends me from Special:Homepage to my user page.Aug 22 2019, 5:00 PM
nray updated the task description. (Show Details)
nray updated the task description. (Show Details)

Change 531743 had a related patch set uploaded (by Jdlrobson; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] currentPage should reflect currentPage not relevant title

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

Change 531588 abandoned by Nray:
🐛 Fix Amc Outreach Drawer/BetaOptInPanel Redirection

Reason:
we probably wont use this

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

Change 531743 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] currentPage should reflect currentPage not relevant title

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

Checked in betalabs - the issue seems to be fixed:

hompage_amc.gif (848×1 px, 146 KB)

@Jdlrobson/@nray I cannot get the outreach drawer to appear. Is there something else I need to do besides make sure that AMC is not on?

@Jdlrobson/@nray I cannot get the outreach drawer to appear. Is there something else I need to do besides make sure that AMC is not on?

Are you testing when logged into https://en.m.wikipedia.beta.wmflabs.org and with AMC off? In production, you will need to have made at least 100 edits in order to see it so make sure you are testing beta (which allows people with >= 0 edits to see it). If you are testing beta and still don't see it, you might already have a localStorage entry. To get around this, you can:

  • After making sure you have AMC turned off, close all previous incognito windows and open up a new incognito window. Log into your account, and you should see it.
Edtadros subscribed.

Test Result

Status: ✅ PASS
OS: macOS Mojave
Browser: Chrome
Device: MBP
Emulated Device: iPhoneX

Test Artifact(s):

QA Steps
  1. Open a new incognito window,
  2. Login to https://en.m.wikipedia.beta.wmflabs.org/wiki/Special:Homepage as a user with AMC disabled
  3. When the outreach drawer appears, click the "Enable advanced mode" button
  4. ✅ AC1: User is redirected back to the page they enabled AMC from (in this case Special:Homepage)

T230927.gif (812×374 px, 741 KB)

DannyS712 subscribed.

[batch] remove patch for review tag from resolved tasks