Page MenuHomePhabricator

MobileFrontend: Make it possible to read the value of wgMFIsSupportedEditRequest in PHP
Closed, DeclinedPublic0.5 Estimated Story Points

Description

Summary

We need a way to know if the MobileFrontend editor could be loaded for a given page for T407377: hCaptcha: Create front-end JS configuration variable that indicates whether an edit to the given page would require hCaptcha completion.

Background

  • ConfirmEdit (CAPTCHA extension) needs to add a JS configuration variable which will be used early in the MobileFrontend edit cycle
    • Therefore, this needs to be loaded on page views and as such we will be using a hook (MakeGlobalVariablesScript) which is documented as expensive due to the content in it being sent back before the page content
  • We therefore should not load the JS configuration variable unless it definitely could be needed
    • This includes not adding the variable if MobileFrontend is not available for the current page view but still installed
  • Currently only a MobileFrontend static protected function can be used to determine this
    • While we could replicate the logic in ConfirmEdit (CAPTCHA extension), it seems more stable to add this static method in some kind of service in a non-static way

Acceptance criteria

Event Timeline

Dreamy_Jazz renamed this task from MobileFrontend: Add to MobileContext service a way to get value of wgMFIsSupportedEditRequest in PHP to MobileFrontend: Make it possible to read the value of wgMFIsSupportedEditRequest in PHP.Wed, Oct 15, 8:41 PM
Dreamy_Jazz updated the task description. (Show Details)
hector.arroyo changed the task status from Open to In Progress.Thu, Oct 16, 2:23 PM
hector.arroyo claimed this task.
hector.arroyo moved this task from Untriaged to MobileFrontend (Editor) on the MobileFrontend board.
hector.arroyo set the point value for this task to 0.5.

Will this require changes to MobileFrontend? If so, is there a way we could move this code out of MobileFrontend? I ask as someone who is actively trying to retire MobileFrontend, so any new code added here creates more obstacles to doing that.

FWIW I have mentioned to Ed that it would be ideal to move the mobile frontend editor code out of MobileFrontend into VisualEditor.

Change #1196711 had a related patch set uploaded (by Harroyo-wmf; author: Harroyo-wmf):

[mediawiki/extensions/MobileFrontend@master] editor: Move isSupportedEditRequest to a dedicated service

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

Will this require changes to MobileFrontend? If so, is there a way we could move this code out of MobileFrontend? I ask as someone who is actively trying to retire MobileFrontend, so any new code added here creates more obstacles to doing that.

FWIW I have mentioned to Ed that it would be ideal to move the mobile frontend editor code out of MobileFrontend into VisualEditor.

Thanks for the context.

We specifically need a stable way to know if the MobileFrontend editor could be used for a given request. That would be used for ConfirmEdit (CAPTCHA extension) to know if we need to add a JS config variable that would then be used by ConfirmEdit (CAPTCHA extension) code.

While just putting this in ConfirmEdit (CAPTCHA extension) is technically an option, this will not have the stability guarantees that we would want and the logic could become out of sync with what is defined in MobileFrontend.

Therefore, I don't think this can go anywhere but MobileFrontend or VisualEditor (if all code is being actively moved there as opposed to there being a plan to). If the definitions get out of sync we risk this causing subtle bugs with the ConfirmEdit (CAPTCHA extension) variable not being loaded then the editor is shown.

If the entire idea of this is a no-go from your point of view, then we would have to have a JS config variable be added to all pages where MobileContext::shouldDisplayMobileView is true which is computed for each request. If that is a better option, then we could always decline this task


As a general point, we have several WIP changes to MobileFrontend to make it support hCaptcha that will be being made soon. These have to go into MobileFrontend per @hector.arroyo comments on gerrit.

I think putting this code in VisualEditor would be more inline with what I was hoping. I've reached out to the editor team to get their input on whether this would make sense.

hector.arroyo changed the task status from In Progress to Stalled.Fri, Oct 17, 9:45 AM

Change #1196056 had a related patch set uploaded (by Harroyo-wmf; author: Harroyo-wmf):

[mediawiki/extensions/ConfirmEdit@master] WiP

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

Change #1196711 abandoned by Harroyo-wmf:

[mediawiki/extensions/MobileFrontend@master] editor: Move isSupportedEditRequest to a dedicated service

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

hector.arroyo changed the task status from Stalled to In Progress.Mon, Oct 20, 10:30 AM

Per discussions in Slack, we are not going to modify any MobileFrontend PHP code and so will no longer need to access wgMFIsSupportedEditRequest in PHP specifically