joomla-cms icon indicating copy to clipboard operation
joomla-cms copied to clipboard

[5.2] Fix reCAPTCHA Invisble error getElementsByClassName().forEach is not a function

Open Fedik opened this issue 1 year ago • 1 comments

Pull Request for Issue https://github.com/joomla/joomla-cms/issues/44294.

Summary of Changes

Fix getElementsByClassName().forEach is not a function for reCAPTCHA Invisble. Caused by https://github.com/joomla/joomla-cms/pull/42797

Testing Instructions

Install Joomla 4, activate reCAPTCHA Invisble somewhere. Update to Joomla 5.

Or, code review, HTMLCollection result of getElementsByClassName() does not have forEach() menthod.

Actual result BEFORE applying this Pull Request

reCAPTCHA Invisble broken

Expected result AFTER applying this Pull Request

reCAPTCHA Invisble works

Link to documentations

Please select:

  • [ ] Documentation link for docs.joomla.org:
  • [x] No documentation changes for docs.joomla.org needed
  • [ ] Pull Request link for manual.joomla.org:
  • [x] No documentation changes for manual.joomla.org needed

Fedik avatar Oct 18 '24 11:10 Fedik

I have tested this item :white_check_mark: successfully on dfc56ea48e0ede3ec52c35cc642527379a806f52


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44306.

Quy avatar Oct 18 '24 15:10 Quy

I tried this fix on 2 sites where reCaptcha invisible broke with this error after upgrading to Joomla 5.2.0, and, while the error went away, the captchas still do not appear. I have both configured to display as inline reCaptchas and none of them are showing.

fire2 avatar Oct 21 '24 21:10 fire2

Thanks for the fix but, it seems bug's solution seems to be requiring more than using a different method. People are using different modules/plugins for forms and captchas. For example I use RSContact and reCAPTCHA v3, and my generated site code doesn't even have a class name of g-recaptcha, as queried by current and proposed code. Something deeper is going on but I cannot find it. May be some J! code which was being used by 3rd party codes altered or deleted somewhere at v5.2 dev. I'll dig as I have time.

YasarYY avatar Oct 25 '24 07:10 YasarYY

I cannot get recaptcha (v2 & v3) work with Joomla 5.2. hcaptcha requests challenge from user every time, (mostly) passive mode is for $99 monthly... So, for my basic needs, I decided to use Aimy Captcha-Less Form Guard (on RSContact and Joomla 5.2).

It seems odd to me that Joomla does not natively support a captcha mechanism 🤔

YasarYY avatar Oct 26 '24 10:10 YasarYY

Tested on my 5.2 site, it does not work. The captcha logo does not appear. When i am using the js-files from Joomla 5.1.4 the captcha works as expected.

tschombes avatar Oct 31 '24 13:10 tschombes

Same issue with Joomla 5.2.1

Fix does not work, had to replace the 3 files with the Joomla 5.1.4 ones

tschombes avatar Nov 08 '24 07:11 tschombes

It seems Joomla's captcha interface (aforementioned js-files and "Default Captcha" global setting) is now broken. Observations at 5.2 and 5.2.1:

  • DJ-EasyContact form plugin: not using Joomla's captcha interface, implicitly implemented, working fine.
  • reCAPTCHA v3 plugin (on RSContact form plugin): using Joomla's captcha interface, does not work.

YasarYY avatar Nov 08 '24 15:11 YasarYY

Tested on my 5.2 site, it does not work. The captcha logo does not appear. When i am using the js-files from Joomla 5.1.4 the captcha works as expected.

Same issue with Joomla 5.2.1

Fix does not work, had to replace the 3 files with the Joomla 5.1.4 ones

@tschombes @fire2 @YasarYY How have you applied the fix from this PR here? As this PR is not merged yet, it was of course not included in 5.2.0 or 5.2.1. If you want to help that it becomes included in the upcoming 5.2.2, you can test that PR, because every PR needs 2 successful human test before it can be merged.

One way to apply the PR would be to download the update zip for that PR here https://artifacts.joomla.org/drone/joomla/joomla-cms/5.2-dev/44306/downloads/80218/ and unpack the following files from that zip:

  • media/plg_captcha_recaptcha_invisible/js/recaptcha.js
  • media/plg_captcha_recaptcha_invisible/js/recaptcha.min.js
  • media/plg_captcha_recaptcha_invisible/js/recaptcha.min.js.gz

Then backup the existing 3 files on your site which you had copied from 5.1.4 and then replace the existing files by the one unpacked from the zip. Finally clear your browser cache to make sure your browser doesn't use the old, cached files and test if it works. Please report back the result in PR #44306 . Thanks in advance.

richard67 avatar Nov 09 '24 12:11 richard67

I have moved all my sites' captchas to either v3 or an other captcha solution. So I'm not able to test this. But, there is an open issue at Sharky's recaptcha-v3, mentioning it does not work with Joomla 5.2. So I tested this PR on it, as you described, and it didn't work. But since that is a v3 plugin, it may be irrelevant to this issue.

This fix seems to make the necessary code change, completing the code update at Minor cleanup for plugins JS PR, including using querySelectorAll instead of getElementsByClassName. But maybe something else is also broken, causing captcha issues at Joomla sites.

So, for me, I cannot test this PR for v2, and it didn't fix v3.

YasarYY avatar Nov 09 '24 21:11 YasarYY

I have tested this item :white_check_mark: successfully on 9c78b5c5f99463ddcc9eef7ebecf4a216d2beb44

I've made a new installation of 4.4.9 and have successfully set up Google Recaptcha v2 invisible and have tested that it works in a contact form.

Then I've updated to 5.2.0 with Live Update ("Next" channel) and have reproduced the issue.

Then I've updated to this PR using Live Update with the custom update URL created by Drone and have verified that the issue is fixed, i.e. the captcha "button" is shown and the JS error mentioned in the issue does not appear. Sending a mail with the contact form protected by the captcha has worked.


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44306.

richard67 avatar Nov 10 '24 14:11 richard67

RTC


This comment was created with the J!Tracker Application at issues.joomla.org/tracker/joomla-cms/44306.

richard67 avatar Nov 10 '24 14:11 richard67

Thank you for this fix!

Hackwar avatar Nov 10 '24 19:11 Hackwar