Page MenuHomePhabricator

SkinMinerva and SkinMinervaBeta should not know about MobileContext
Closed, ResolvedPublic3 Estimated Story Points

Description

For Minerva to be pulled out of the MobileFrontend repository the skin portion needs to be agnostic to the existence of MobileFrontend.
MobileContext will stay in MobileFrontend so any references to this class should be ported to MobileFrontend.skin.hooks.

Testing Notes

N.B. for the following you should test on the mobile version of the Beta Cluster wiki.

The features immediately affected by the change(s) are:

  • Some entries of the hamburger menu on the mobile site. You should test: whether you can log in/out; you can access the mobile options page.
  • The "font (size) changer" on the mobile options page.
  • Section collapsing (and expansion). You should test whether you see collapsed sections and can expand/collapse them.
  • The "Categories" button. You should test whether you see the button at the bottom of a page (that is in one or more categories!) ---

There appear to be a handful of things that SkinMinerva gets from MobileContext:

  1. Whether the user is a member of the beta group (or "MobileFrontend is in beta mode" as we like to say) – seriously, we should align our language with that of the codebase…
  2. Whether the mobile view should be displayed (see MobileContext#shouldDisplayMobileView).
  3. Access to the global configuration, i.e. an instance of GlobalVarConfig with the default 'wg' prefix.
  4. Access to something capable of generating URLs for the mobile domain (see MobileContext#getMobileUrl).

1, 2, and 3 are just state. 4 should be extracted into its own class, which would hide away the complexity of generating URLs and for which domains. All of them, however, could be injected:

includes/SkinMinerva.php
public function __construct( $shouldDisplayMobileView, $isBetaGroupMember, Config $config, Router $router ) {
  $this->isMobileMode = $shouldDisplayMobileView;
  $this->isBetaGroupMember = $isBetaGroupMember;
  $this->config = $config;
  $this->router = $router;

  // ...
}

Plan (YMMV)

  1. Audit occurrances of $this->isMobileMode (according to T148197#2760151 the skin shouldn't be varying its behaviour)
  2. Inject an instance of GlobalVarConfig via the constructor.
  3. [Register a factory function with SkinFactory](https://github.com/wikimedia/mediawiki/blob/master/includes/skins/SkinFactory.php#L54-L73).
  4. Replace all calls to SkinMinerva#getMFConfig with $this->config.
  5. Create MobileFrontend\Router class, which has the following shape, and inject it via the constructor.
includes/Router.php
class Router {
  public function getLoginUrl( array $returnTo ) {
  }

  public function getLogoutUrl( array $returnTo ) {
  }
}
  1. Replace all calls to MobileContext#getMobileUrl with the appropriate Router method.

Event Timeline

Jdlrobson claimed this task.
Jdlrobson raised the priority of this task from to Low.
Jdlrobson updated the task description. (Show Details)
Jdlrobson added subscribers: Fuzheado, LikeLifer, Niharika and 15 others.
phuedx updated the task description. (Show Details)
Jdlrobson raised the priority of this task from Low to Medium.Dec 16 2016, 8:28 PM

Upping priority for visibility as I think this is important.

Change 345000 had a related patch set uploaded (by Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Mobile specific skin changes are enabled inside a hook

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

@phuedx: that patchset looks great, I didn't +2 only because I pushed couple small fixes (code hygiene + fixed incorrect constant)

Jdlrobson set the point value for this task to 3.Apr 4 2017, 11:49 PM

The second part is reviewed and +2ed and this is now waiting on https://gerrit.wikimedia.org/r/345000
@pmiazga has +1ed that was hoping for some input from @phuedx
Would be great if we could get this done before kicking off the next sprint.

Change 345000 had a related patch set uploaded (by Phuedx; owner: Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Mobile specific skin changes are enabled inside a hook

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

Anyone remember where the original description of this task came from? I remember writing it but I really don't remember why I wrote it.

Follow-up actions from CR:

  • Define "option" and/or "feature" inside and outside of the codebase.

Change 345000 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] Mobile specific skin changes are enabled inside a hook

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

I just need to add testing notes…

I ran some tests on Android and iOS covering the following bullets and I had a couple faiures. Here are the results thus far:

Tested on:
Galaxy S6 Android 5.0 - Android Browser 5.0
Galaxy S6 Android 5.0 - Chrome 35
Nexus 6P Android 7.0 - Chrome 55
iPhone 6S iOS 9.0 - Safari 9.0

PASSED - Some entries of the hamburger menu on the mobile site. You should test: whether you can log in/out; you can access the mobile options page.
FAILED - The "font (size) changer" on the mobile options page.
PASSED - Section collapsing (and expansion). You should test whether you see collapsed sections and can expand/collapse them.
FAILED - The "Categories" button. You should test whether you see the button at the bottom of a page (that is in one or more categories!)

Changing the font size does not appear to have any effect on the font. It was the same on all the platforms.

I do not see the category button on any articles. I tried the articles for String Section and Dog on beta and production respectively. The production articles display the categories button and the beta articles do not, but I am not sure the 'categories' are present on the beta site.

Interesting. Categories and font changer works fine for me locally but not on the beta cluster...

Jdlrobson added a subscriber: ABorbaWMF.

Looks like the JS/CSS is not being loaded for back to top button, font size changer and categories feature.

I'm seeing the related markup changes, but not the correct JS files being loaded.
It seems like a race condition. SkinMinerva::getContextSpecificModules is being called before the onBeforePageDisplayMobile hook has its opportunity to change state, although I'm not sure why this doesn't happen locally.

Change 347671 had a related patch set uploaded (by Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] Add mobile specific modules inside BeforePageDisplayMobile hook

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

This makes sense.
getDefaultModules is called before the BeforePageDisplay and thus the BeforePageDisplayMobile method.
I'm not sure how we did not catch this in testing. I'm guessing caching falsely gave us confidence.

It's actually a little more serious than I first thought. If there are any wikis that disable editing they will not load the toggling code - skins.minerva.editor pulls in the toggling code as a side effect which minimises damage.

This seems like a flaw in the architecture to me.

Change 347786 had a related patch set uploaded (by Jdlrobson):
[mediawiki/extensions/MobileFrontend@master] setMobileOptions at time of skin creation

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

Change 347786 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@master] setMobileOptions at time of skin creation

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

Change 347885 had a related patch set uploaded (by Jdlrobson):
[mediawiki/extensions/MobileFrontend@wmf/1.29.0-wmf.20] setMobileOptions at time of skin creation

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

Change 347885 merged by jenkins-bot:
[mediawiki/extensions/MobileFrontend@wmf/1.29.0-wmf.20] setMobileOptions at time of skin creation

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

Mentioned in SAL (#wikimedia-operations) [2017-04-12T18:26:56Z] <thcipriani@tin> Synchronized php-1.29.0-wmf.20/extensions/MobileFrontend: SWAT: [[gerrit:347885|setMobileOptions at time of skin creation]] T125588 (duration: 00m 46s)

Jdlrobson moved this task from Needs Code Review to Needs QA on the Reading-Web-Sprint-95 board.
Jdlrobson removed a project: Patch-For-Review.

@ABorbaWMF can you have another look

Change 347671 abandoned by Jdlrobson:
Add mobile specific modules inside BeforePageDisplayMobile hook

Reason:
Almost forgot this. Piotr feel free to abandon my patches if you ever feel the need. I will never get offended :)

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

I was able to retest this on the beta site and it appears to be working correctly except for one small issue (listed below).

PASSED - Some entries of the hamburger menu on the mobile site. You should test: whether you can log in/out; you can access the mobile options page.
PASSED - The "font (size) changer" on the mobile options page.
PASSED - Section collapsing (and expansion). You should test whether you see collapsed sections and can expand/collapse them.
PASSED - The "Categories" button. You should test whether you see the button at the bottom of a page (that is in one or more categories!)

Right now clicking on the Categories results in a page that doesn't populate with results. I found this to be true on Beta and Production when viewing the articles for Dog and String Section.

T162922 tracks the issue with the categories overlay. Thanks for the thorough review @ABorbaWMF !