Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from
Nov 10, 2024

Conversation

Fedik
Copy link
Member

@Fedik Fedik commented Oct 18, 2024

Pull Request for Issue #44294.

Summary of Changes

Fix getElementsByClassName().forEach is not a function for reCAPTCHA Invisble.
Caused by #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:
  • No documentation changes for docs.joomla.org needed
  • Pull Request link for manual.joomla.org:
  • No documentation changes for manual.joomla.org needed

@Quy
Copy link
Contributor

Quy commented Oct 18, 2024

I have tested this item ✅ successfully on dfc56ea


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

@Quy Quy mentioned this pull request Oct 21, 2024
@Quy Quy added this to the Joomla! 5.2.1 milestone Oct 21, 2024
@fire2
Copy link

fire2 commented Oct 21, 2024

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.

@YasarYY
Copy link

YasarYY commented Oct 25, 2024

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
Copy link

YasarYY commented Oct 26, 2024

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 🤔

@tschombes
Copy link

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
Copy link

Same issue with Joomla 5.2.1

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

@YasarYY
Copy link

YasarYY commented Nov 8, 2024

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.

@richard67
Copy link
Member

richard67 commented Nov 9, 2024

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.

@YasarYY
Copy link

YasarYY commented Nov 9, 2024

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.

@richard67
Copy link
Member

I have tested this item ✅ successfully on 9c78b5c

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
Copy link
Member

RTC


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

@joomla-cms-bot joomla-cms-bot removed this from the Joomla! 5.2.2 milestone Nov 10, 2024
@joomla-cms-bot joomla-cms-bot added the RTC This Pull Request is Ready To Commit label Nov 10, 2024
@richard67 richard67 added this to the Joomla! 5.2.2 milestone Nov 10, 2024
@Hackwar Hackwar merged commit 97fcd9d into joomla:5.2-dev Nov 10, 2024
3 of 4 checks passed
@joomla-cms-bot joomla-cms-bot removed the RTC This Pull Request is Ready To Commit label Nov 10, 2024
@Hackwar
Copy link
Member

Hackwar commented Nov 10, 2024

Thank you for this fix!

@Fedik Fedik deleted the fix-44294 branch November 11, 2024 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug NPM Resource Changed This Pull Request can't be tested by Patchtester PR-5.2-dev
Projects
None yet
Development

Successfully merging this pull request may close these issues.

reCAPTCHA Invisble plugin fails execution after Joomla! Core update 5.2.0
9 participants