Hello,

When adding a captcha point it prefills the form ID.
This is very nice however when you have a large form ID (Larger than 64 characters) you cannot make the captcha work on this form.

Even if you change the "machine name" it doesn't work.

How do I get such a large form ID ?
Well I embed Webforms via paragraphs and then they receive a large ID.

A patch is attached to resolve this issue.

Kind regards

CommentFileSizeAuthor
#21 captcha-form_id_length_64_characters_too_small-2912341-21.patch6.33 KBbnjmnm
#20 captcha-form_id_length_64_characters_too_small-2912341-20.patch3.96 KBbnjmnm
#18 captcha-form_id_length_64_characters_too_small-2912341-18.patch2.28 KBbnjmnm
#17 captcha-form_id_length_64_characters_too_small-2912341-17.patch1.42 KBbnjmnm
#15 captcha-form_id_length_64_characters_too_small-2912341-15.patch1.36 KBelachlan
#14 captcha-form_id_length_64_characters_too_small-2912341-14.patch1.14 KBbnjmnm
#12 2912341-12.patch1.34 KBelachlan
#10 captcha-form_id_length_64_characters_too_small-2912341-10.patch1.12 KBbnjmnm
#8 captcha-disappear-large-formid.png148.9 KBsaravanaprasanth
#8 captcha-working.png156.12 KBsaravanaprasanth
#5 large-formid1.png44.56 KBsaravanaprasanth
#5 large-formid.png84.44 KBsaravanaprasanth
#5 Patch applied message.png42.08 KBsaravanaprasanth
#3 captcha-form_id_length_64_characters_too_small-2912341-3.patch715 byteshswong3i
form_id_length_64_characters_too_small.patch716 bytesMschudders
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Mschudders created an issue. See original summary.

Status: Needs review » Needs work

The last submitted patch, form_id_length_64_characters_too_small.patch, failed testing. View results

hswong3i’s picture

Status: Needs work » Needs review
FileSize
715 bytes

Refer to class MachineName, the limitation of max 64 characters due to its default #maxlength:

#maxlength: (optional) Maximum allowed length of the machine name. Defaults to 64.

Patch update #maxlength of both label and formId into 255, so should solve this issue correctly.

saravanaprasanth’s picture

Assigned: Unassigned » saravanaprasanth
saravanaprasanth’s picture

Status: Needs review » Reviewed & tested by the community
FileSize
42.08 KB
84.44 KB
44.56 KB

Hi ,

I have applied the patch #3(Patch applied cleanly). After applying the patch I can able to create the large Form id. Also, I can able to edit/change the form id of the existing form to the large form id but the issue still appearing needs to be reworked.(Captcha not working).

For the larger form id, the captcha was not appearing/working.

Attached screenshots of the same.

saravanaprasanth’s picture

Assigned: saravanaprasanth » Unassigned
saravanaprasanth’s picture

saravanaprasanth’s picture

Status: Reviewed & tested by the community » Needs work
FileSize
156.12 KB
148.9 KB

Hi ,

I have applied the patch #3(Patch applied cleanly). After applying the patch I can able to create the large Form id. Also, I can able to edit/change the form id of the existing form to the large form id but the issue still appearing needs to be reworked.(Captcha not working).

For the larger form id, the captcha was not appearing/working.

Attached screenshots of the same.

couturier’s picture

We'd love to get this patch working and applied but also need more help with the 8.x port in general.

bnjmnm’s picture

The attached patch fixed the issue for me. Instead of changing the char limits on the form, I changed the condition in captcha_form_alter to find the Captcha Point entity based on form id instead of entity id, as the two aren't guaranteed to match.

elachlan’s picture

Status: Needs work » Needs review
elachlan’s picture

Status: Needs review » Needs work

The last submitted patch, 12: 2912341-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bnjmnm’s picture

elachlan’s picture

Status: Needs review » Needs work

The last submitted patch, 15: captcha-form_id_length_64_characters_too_small-2912341-15.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

bnjmnm’s picture

Had to rewrite the patch to accommodate captcha points provided by the module on install, which have their label property set to null.

Ideally, I'd prefer to have the default config entities have label: match the formId: value instead of being null so two queries aren't necessary in form_alter, but this wouldn't work for users with the module already installed.

bnjmnm’s picture

elachlan’s picture

Could we write a test for this? So we don't end up breaking it later?

bnjmnm’s picture

bnjmnm’s picture

bnjmnm’s picture

Status: Needs work » Needs review

  • elachlan committed c0e8dc5 on 8.x-1.x authored by bnjmnm
    Issue #2912341 by bnjmnm, elachlan, Mschudders, hswong3i,...
elachlan’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

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

Joe Huggans’s picture

This patch has failed for me when updating core to 8.6.13, are we safe to just use - captcha 8.x-1.x-dev ?

Edit: tested dev and isn't working, can't seem to get anything to work for me

patching file captcha.module
Hunk #1 FAILED at 164.
Hunk #2 FAILED at 183.
Hunk #3 succeeded at 152 with fuzz 2 (offset -40 lines).
2 out of 3 hunks FAILED -- saving rejects to file captcha.module.rej
patching file modules/captcha_long_form_id_test/captcha_long_form_id_test.info.yml
patching file modules/captcha_long_form_id_test/captcha_long_form_id_test.routing.yml
patching file modules/captcha_long_form_id_test/src/Form/LongIdForm.php
patching file src/Tests/CaptchaTestCase.php
Hunk #1 succeeded at 18 (offset -1 lines).
Hunk #2 succeeded at 259 (offset -12 lines).

patch '-p0' --no-backup-if-mismatch -d 'web/modules/contrib/captcha' < '/tmp/5c94dd0276796.patch'
can't find file to patch at input line 5

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/captcha.module b/captcha.module
|index 9d787d0..ff61e56 100755
|--- a/captcha.module
|+++ b/captcha.module
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

3 out of 3 hunks ignored

patching file b/modules/captcha_long_form_id_test/captcha_long_form_id_test.info.yml

patching file b/modules/captcha_long_form_id_test/captcha_long_form_id_test.routing.yml

patching file b/modules/captcha_long_form_id_test/src/Form/LongIdForm.php

can't find file to patch at input line 141

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/src/Tests/CaptchaTestCase.php b/src/Tests/CaptchaTestCase.php
|index c386d4c..8fa95e5 100755
|--- a/src/Tests/CaptchaTestCase.php
|+++ b/src/Tests/CaptchaTestCase.php
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

2 out of 2 hunks ignored

patch '-p2' --no-backup-if-mismatch -d 'web/modules/contrib/captcha' < '/tmp/5c94dd0276796.patch'
can't find file to patch at input line 5

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/captcha.module b/captcha.module
|index 9d787d0..ff61e56 100755
|--- a/captcha.module
|+++ b/captcha.module
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

3 out of 3 hunks ignored

patching file captcha_long_form_id_test/captcha_long_form_id_test.info.yml

patching file captcha_long_form_id_test/captcha_long_form_id_test.routing.yml

patching file captcha_long_form_id_test/src/Form/LongIdForm.php

can't find file to patch at input line 141

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/src/Tests/CaptchaTestCase.php b/src/Tests/CaptchaTestCase.php
|index c386d4c..8fa95e5 100755
|--- a/src/Tests/CaptchaTestCase.php
|+++ b/src/Tests/CaptchaTestCase.php
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

2 out of 2 hunks ignored

patch '-p4' --no-backup-if-mismatch -d 'web/modules/contrib/captcha' < '/tmp/5c94dd0276796.patch'
can't find file to patch at input line 5

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/captcha.module b/captcha.module
|index 9d787d0..ff61e56 100755
|--- a/captcha.module
|+++ b/captcha.module
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

3 out of 3 hunks ignored

can't find file to patch at input line 61

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/modules/captcha_long_form_id_test/captcha_long_form_id_test.info.yml b/modules/captcha_long_form_id_test/captcha_long_form_id_test.info.yml
|new file mode 100644
|index 0000000..93b2b61
|--- /dev/null
|+++ b/modules/captcha_long_form_id_test/captcha_long_form_id_test.info.yml
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

1 out of 1 hunk ignored

can't find file to patch at input line 73

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/modules/captcha_long_form_id_test/captcha_long_form_id_test.routing.yml b/modules/captcha_long_form_id_test/captcha_long_form_id_test.routing.yml
|new file mode 100644
|index 0000000..0fc46ae
|--- /dev/null
|+++ b/modules/captcha_long_form_id_test/captcha_long_form_id_test.routing.yml
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

1 out of 1 hunk ignored

patching file Form/LongIdForm.php

can't find file to patch at input line 141

Perhaps you used the wrong -p or --strip option?

The text leading up to this was:
--------------------------

|diff --git a/src/Tests/CaptchaTestCase.php b/src/Tests/CaptchaTestCase.php
|index c386d4c..8fa95e5 100755
|--- a/src/Tests/CaptchaTestCase.php
|+++ b/src/Tests/CaptchaTestCase.php
--------------------------

File to patch:

Skip this patch? [y]

Skipping patch.

2 out of 2 hunks ignored

Joe Huggans’s picture

#3 worked for me after trying other patches. 8.x-1.0-beta1