Page MenuHomePhabricator

hCaptcha: Create front-end JS configuration variable that indicates whether an edit to the given page would require hCaptcha completion
Closed, ResolvedPublic0.5 Estimated Story Points

Description

Summary

We want to display ConfirmEdit (CAPTCHA extension) hCaptcha in VisualEditor and MobileFrontend, but in these situations we need to know this before they open the edit form. Therefore, a mw.config variable is needed to determine if hCaptcha needs to be shown

Background

  • Both the VisualEditor and MobileFrontend integrations with hCaptcha need to know in advance whether the hCaptcha captcha needs to be shown for the edit to go through
    • This is so that they can emulate the same behaviour as the wikitext editor has, where if we know in a general sense that a hCaptcha captcha needs to be done it will be shown once they open the edit form
  • Because these forms can be opened without a refresh of the page, we will need to set some value that exists even on reads. This could therefore be a JS configuration variable.
    • This JS configuration variable needs to contain:
      • Whether a captcha needs to be completed
      • What kind of captcha needs to be completed
  • Using a combined variable for both the VisualEditor and MobileFrontend integrations will help to reduce the overall number of JS configuration variables and reduce the impact this has on page load times

Technical notes

  • Some JS configuration variable like wgConfirmEditCaptchaNeededForEdit would be defined
    • It could be unset if it's not needed (i.e. VisualEditor and MobileFrontend could not be used on the given page view) and unset if a captcha is not required for a generic edit
    • If it is needed, then the value should be the type of captcha that is required (i.e. hcaptcha if hCaptcha is needed and fancycaptcha if FancyCaptcha is needed)
      • We can determine this through a call to Hooks::getInstance( 'edit' )->shouldCheck() which will return whether a captcha is needed for the edit. We would check the instance returned by Hooks::getInstance( 'edit' ) to determine what type of captcha is being returned

Acceptance criteria

  • A way to know whether a captcha is needed for the VisualEditor / MobileFrontend interfaces when the edit forms open is added

Event Timeline

Change #1196529 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[mediawiki/extensions/ConfirmEdit@master] [WIP] Add wgConfirmEditCaptchaNeededForGenericEdit

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

Change #1196662 had a related patch set uploaded (by Dreamy Jazz; author: Dreamy Jazz):

[integration/config@master] Zuul: [mediawiki/extensions/ConfirmEdit] Add VisualEditor and MobileFrontend deps

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

Change #1196662 merged by jenkins-bot:

[integration/config@master] Zuul: ConfirmEdit extension: Add VisualEditor and MobileFrontend deps

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

Change #1196529 merged by jenkins-bot:

[mediawiki/extensions/ConfirmEdit@master] Add wgConfirmEditCaptchaNeededForGenericEdit

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