Page MenuHomePhabricator

Update ConvenientDiscussions to use mw.libs.confirmEdit.CaptchaWidget instead of mw.libs.confirmEdit.CaptchaInputWidget
Closed, ResolvedPublic

Description

Summary

In T422913: Rework mw.libs.confirmEdit.CaptchaInputWidget to not always require an input field, the mw.libs.confirmEdit.CaptchaInputWidget class was replaced with the mw.libs.confirmEdit.CaptchaWidget class. The latter supports hCaptcha which is being rolled out slowly to more editing interfaces. Convenient-Discussions should use the new module over the soon to be deprecated module.

Background & Technical details

  • mw.libs.confirmEdit.CaptchaInputWidget relies on the idea that the captcha will always have an input field to be rendered
    • However hCaptcha violates this assumption as it renders it's own widget and does not use a text field for the user to enter text
    • Therefore, the CaptchaInputWidget needed refactoring to support hCaptcha and a rename to make it clear that there will not always be a input field
  • This means that the mw.libs.confirmEdit.CaptchaInputWidget class has been deprecated and Convenient-Discussions should use the mw.libs.confirmEdit.CaptchaWidget class instead
    • The CaptchaWidget class still supports all the captcha types supported by CaptchaInputWidget, so changing this does not represent a backwards step in compatibility

Acceptance criteria

  • Convenient-Discussions uses mw.libs.confirmEdit.CaptchaWidget instead of mw.libs.confirmEdit.CaptchaInputWidget

Event Timeline

@Dreamy_Jazz I need to support old MediaWiki versions. How will I be able to detect whether mw.libs.confirmEdit.CaptchaWidget is functional already? Or testing for 'CaptchaWidget' in mw.libs.confirmEdit is enough?

So, as I see from your commit to DT, mw.libs.confirmEdit.CaptchaWidget works quite a bit differently from mw.libs.confirmEdit.CaptchaInputWidget,

  1. requiring separate updating and rendering steps (with mw.libs.confirmEdit.CaptchaInputWidget, calling the constructor was enough);
  2. requiring the container to be added to the DOM before the captcha is rendered (whereas mw.libs.confirmEdit.CaptchaInputWidget, on the contrary, supplied you with an element to add to the DOM).

Also, I won't implement initial captcha as CD users are unlikely to make their very first edit with CD, and if they are (e.g. on a new wiki, or with a new account), a failure captcha is quite enough.

@Dreamy_Jazz I need to support old MediaWiki versions. How will I be able to detect whether mw.libs.confirmEdit.CaptchaWidget is functional already? Or testing for 'CaptchaWidget' in mw.libs.confirmEdit is enough?

I'd recommend using mw.loader.getState as you already do in https://github.com/jwbth/convenient-discussions/blob/ea3a668bdc4dd26edef630384cd60335ce1d2458/src/loader/convenientDiscussions.loader.js#L208 but duplicate that for ext.confirmEdit.CaptchaWidget.

Then if the module is defined, it should be loaded and mw.libs.confirmEdit would contain CaptchaWidget. For older wikis without this then then the module won't be loaded and mw.libs.confirmEdit would not contain CaptchaWidget

So, as I see from your commit to DT, mw.libs.confirmEdit.CaptchaWidget works quite a bit differently from mw.libs.confirmEdit.CaptchaInputWidget,

  1. requiring separate updating and rendering steps (with mw.libs.confirmEdit.CaptchaInputWidget, calling the constructor was enough);
  2. requiring the container to be added to the DOM before the captcha is rendered (whereas mw.libs.confirmEdit.CaptchaInputWidget, on the contrary, supplied you with an element to add to the DOM).

Yes, these are both due to the extra requirements for hCaptcha:

  • hCaptcha requires that rendering occur once the container element exists in the DOM (if the element does not exist in the DOM it fails to work even when the container is later added to the DOM). I suspect other CAPTCHAs that may be supported later as required (such as ReCAPTCHA and Turnstile) would require this too
  • The separate update step was done so that you could call an update on an CAPTCHA that was already rendered and have it re-rendered only if it that is required (such as for hCaptcha)

Also, I won't implement initial captcha as CD users are unlikely to make their very first edit with CD, and if they are (e.g. on a new wiki, or with a new account), a failure captcha is quite enough.

For sure, that seems sensible to not bother with the initial captcha for CD (especially as it adds additional complexity)

Dreamy_Jazz changed the task status from Stalled to Open.May 12 2026, 9:35 PM

Un-stalling this to reflect the current state