Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment | File | Size | Author |
---|---|---|---|
#21 | captcha-form_id_length_64_characters_too_small-2912341-21.patch | 6.33 KB | bnjmnm |
| |||
#8 | captcha-disappear-large-formid.png | 148.9 KB | saravanaprasanth |
#8 | captcha-working.png | 156.12 KB | saravanaprasanth |
#5 | large-formid.png | 84.44 KB | saravanaprasanth |
#5 | Patch applied message.png | 42.08 KB | saravanaprasanth |
Comments
Comment #3
hswong3i CreditAttribution: hswong3i commentedRefer to class MachineName, the limitation of max 64 characters due to its default
#maxlength
:Patch update
#maxlength
of bothlabel
andformId
into 255, so should solve this issue correctly.Comment #4
saravanaprasanth CreditAttribution: saravanaprasanth at DrupalPartners for Innoppl Technologies Pvt. Ltd commentedComment #5
saravanaprasanth CreditAttribution: saravanaprasanth at DrupalPartners commentedHi ,
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.
Comment #6
saravanaprasanth CreditAttribution: saravanaprasanth at DrupalPartners commentedComment #7
saravanaprasanth CreditAttribution: saravanaprasanth at DrupalPartners commentedComment #8
saravanaprasanth CreditAttribution: saravanaprasanth at DrupalPartners commentedHi ,
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.
Comment #9
couturier CreditAttribution: couturier as a volunteer commentedWe'd love to get this patch working and applied but also need more help with the 8.x port in general.
Comment #10
bnjmnmThe 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.
Comment #11
elachlan CreditAttribution: elachlan commentedComment #12
elachlan CreditAttribution: elachlan commentedComment #14
bnjmnmUpdated patch based on test results
Comment #15
elachlan CreditAttribution: elachlan commentedComment #17
bnjmnmHad 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.
Comment #18
bnjmnmReroll
Comment #19
elachlan CreditAttribution: elachlan commentedCould we write a test for this? So we don't end up breaking it later?
Comment #20
bnjmnmAdded test
Comment #21
bnjmnmUpdate to include testing module
Comment #22
bnjmnmComment #24
elachlan CreditAttribution: elachlan commentedComment #26
Joe HuggansThis 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
Comment #27
Joe Huggans#3 worked for me after trying other patches. 8.x-1.0-beta1