Insert captcha widget even if placement is NULL

Created on 18 February 2025, 5 months ago

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.

📌 Task
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany jurgenhaas Gottmadingen

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @jurgenhaas
  • 🇩🇪Germany jurgenhaas Gottmadingen
  • Pipeline finished with Failed
    5 months ago
    Total: 415s
    #427787
  • Status changed to Needs review 7 days ago
  • First commit to issue fork.
  • 🇩🇪Germany Anybody Porta Westfalica

    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.

  • 🇩🇪Germany jurgenhaas Gottmadingen

    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.

  • 🇩🇪Germany Anybody Porta Westfalica

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

  • 🇩🇪Germany Anybody Porta Westfalica
  • Pipeline finished with Skipped
    7 days ago
    #554974
  • Pipeline finished with Skipped
    7 days ago
    #555043
Production build 0.71.5 2024