Problem/Motivation

CAPTCHA persistence settings are ignored when using certain CAPTCHA types, such as reCAPTCHA or Turnstile. As a result, the CAPTCHA is always displayed on forms, regardless of the configured persistence options.

This issue occurs because when the cacheable attribute is set in hook_captcha_captcha, the CAPTCHA module does not update the CAPTCHA status to 'resolved' after a successful completion. As a result, persistence fails, as it primarily depends on the status being correctly updated.

Steps to reproduce

  1. Enable and configure the reCAPTCHA module or another CAPTCHA module that supports a cacheable CAPTCHA type (e.g., the Turnstile module), as the CAPTCHA module itself does not provide a cacheable type.
  2. At /admin/config/people/captcha, select the option "Omit challenges on all forms once the user successfully responds to any challenge on the site."
  3. Add a reCAPTCHA CAPTCHA to a form.
  4. Complete the form, solving the CAPTCHA, and submit it.
  5. Revisit the form and observe that the CAPTCHA is still required.

Proposed resolution

Fix how captcha status is handled when cacheable attribute is set.

Remaining tasks

  • Resolve the isssue.
  • Add tests.

User interface changes

API changes

Data model changes

Issue fork captcha-3496865

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

murat_kekic created an issue. See original summary.

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

anybody’s picture

@murat_kekic thank you! Could we maybe have a test that fails before these fixes and is green when fixed? That would ensure it's working as expected. Maybe as separate branch?

murat_kekic’s picture

Status: Active » Needs review

I ran test with drupal.org. Only the expected tests are failing: https://git.drupalcode.org/project/captcha/-/merge_requests/117

anybody’s picture

Status: Needs review » Needs work

Really nice @murat_kekic thank you!

Happy to merge this, once the comments are resolved and community RTBC'd it! :)

murat_kekic’s picture

Status: Needs work » Needs review

Ready for review

j_s’s picture

Does this need a re-roll for changes?

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

j_s’s picture

Status: Needs review » Reviewed & tested by the community

Tested and confirmed this MR currently fixes the issue in my testing. Thanks!