Problem/Motivation

Marking as task since I can't decide if this is a bug report or a feature request.

My use case is that we have forms that get built by a form alter of a different module, in my case that's ECA. And because the form alter of ECA gets called later than the form alter of captcha, the form doesn't have any submit buttons yet and therefore captcha doesn't insert the widget.

However, the method $captchaService->insertCaptchaElement is written in a way that the second argument for the placement can be NULL and the insertion still works.

Proposed resolution

Call the insert function even if placement is NULL.

Issue fork captcha-3507522

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

jurgenhaas created an issue. See original summary.

jurgenhaas’s picture

Status: Active » Needs review

anybody made their first commit to this issue’s fork.

anybody’s picture

Thanks @jurgenhaas - how sure are we, that this doesn't introduce any unwanted side-effects? Generally I'd be fine with this change, but I'm not really sure about possible edge-cases, especially in existing installations.

jurgenhaas’s picture

how sure are we, that this doesn't introduce any unwanted side-effects?

I'm pretty certain. Here is why:

  • The method $captchaService->insertCaptchaElement is explicitly built to allow for a NULL placement. That must have been done on purpose.
  • The NULL value for placements can only happen on forms without buttons. But the assumption that forms without buttons shouldn't get a captcha is not reasonable.

So, what's the risk that I'm wrong? Well, if there is an unintended side-effect, it could only be on forms with no buttons. Do they exist and why? I think, chances are negligible.

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks for your feedback @jurgenhaas. I agree the risks are low enough, the benefit is much higher. Let's merge this.

anybody’s picture

Status: Reviewed & tested by the community » Fixed

  • anybody committed 7480d28d on 2.x authored by jurgenhaas
    Issue #3507522 by jurgenhaas, anybody: Insert captcha widget even if...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.