Problem/Motivation
Reloading an image captcha triggers a JS error resulting in the user being redirected to JSON.
Steps to reproduce
- Load a page showing an image captcha.
- Click the reload icon below the captcha to regenerate the image.
Expected result
Captcha image replaced with new version via AJAX.
Actual result
JS error "Uncaught ReferenceError: FALSE is not defined" and subsequent redirect to JSON.
Uncaught ReferenceError: FALSE is not defined
at HTMLAnchorElement.<anonymous> (image_captcha_refresh.js?v=10.4.1:47:9)
at HTMLAnchorElement.dispatch (jquery.min.js?v=3.7.1:2:40035)
at v.handle (jquery.min.js?v=3.7.1:2:38006)
(anonymous) @ image_captcha_refresh.js?v=10.4.1:47
dispatch @ jquery.min.js?v=3.7.1:2
v.handle @ jquery.min.js?v=3.7.1:2Understand this errorAI
Proposed resolution
Fix the JS error by replacing FALSE with false.
Remaining tasks
Commit.
User interface changes
None.
Introduced terminology
None.
API changes
None.
Data model changes
None.
Release notes snippet
n/a
Original report
hi.
drupal 10.3.8
php 8.3.6
update captcha to 2.0.7
erro in capcha reload and show this message ;
{"status":1,"message":"","data":{"url":"\/image-captcha-generate\/19\/1732275322","token":"37NDuQbGZHTvQyC9u3_RdHaRgyBZoyS8jCne2WjmQ6I","sid":"19"}}
| Comment | File | Size | Author |
|---|
Issue fork captcha-3489166
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
Comment #2
arunsahijpal commentedHi @bolaghi,
I've tested it on
drupal 10.3.9
php 8.3.14
captcha 2.0.7
and it does not show any error.
Comment #3
jordik commentedSame error as in the description.
drupal 10.3.10
captcha 2.0.7
Reverting to captcha 2.0.6. makes the error disappear and captcha refreshes as expected.
Comment #5
jordik commentedThe image_captcha_refresh.js was changed in 2.0.7 to return "FALSE" instead of "false" which causes a JSON error (can only handle lowercase booleans).
Changing it back to "false" resolves the issue.
MR created.
Comment #6
jordik commentedComment #7
jordik commentedComment #8
bolaghi commentedthank you @jordik , #5 Fixed the problem.
Comment #9
7r3y commentedHi,
Drupal 11.0.9
PHP 8.3.6
Captcha 2.0.7
The problem still exists even after I changed FALSE to false in the image_captcha_refresh.js file as described in #5.
Update: I tried with dev version of module but the result is still the same.
Comment #10
suraj_vantagode commentedHi,
Facing the same issue with the below versions:
Drupal 10.3.8
PHP 8.1.31
Captcha 2.0.6
The image_captcha_refresh.js is already set as "false", but I am still facing an issue.
Comment #11
jordik commentedTry rebuilding the cache and then refreshing the page.
Comment #12
shasha821110 commentedthe change from 'FALSE' to 'false' works for me. Thanks.
Comment #13
quilx commentedThe error mentioned in #4 is more than obvious. The file image_captcha_refresh.js is a Javascript file and in javascript FALSE is not a boolean literal. The error is confirmed also by web browsers. The Javascript engine throws the following exception that can be seen in the Console when it encounters FALSE:
By changing FALSE to false the problem is solved.
If you make this change then reload the page with "CTRL + SHIFT + R" in order to load the changed version and not the version cached by your browser.
Comment #14
tamnv commentedHi
I created a patch for changing from FALSE to false which work well from our side
Comment #15
cgrouge commentedConfirming the patch in #14 changing FALSE to false fixes the error for me.
Drupal 10.3.9
Captcha 2.0.7
Comment #16
7r3y commentedRe: #11
After rebuilding the cache and refreshing the page, the issue has indeed been resolved. Thank you!
Comment #17
feyp commentedUpdated IS. Code in the MR looks good to me and fixes the problem. Alternatively, #14 provides the changes from the MR as a patch file. The MR pipeline has warnings, but it looks like those were not newly introduced by the suggested changes. We already have a bunch of users in previous comments confirming this approach fixes the error for them. I'm going to go ahead an RTBC this.
Comment #18
anybodyThanks, good fix! Indeed in JS it should be lowercase!