Closed (outdated)
Project:
reCAPTCHA
Version:
8.x-3.x-dev
Component:
reCAPTCHA V3
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
12 May 2020 at 14:02 UTC
Updated:
4 Sep 2024 at 16:57 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
timme77 commentedSame problem here. I'm on Drupal 8.8.5.
Comment #3
drupal.ninja03 commentedI am using Drupal core 8.8.6, PHP 7.2 and I am unable to reproduce this error. Please provide the steps to reproduce.
Comment #4
stevensf commentedSame problem...
Drupal v8.8.5 - PHP 7.3 - Webform 8.5.15 - Captcha 8.1.1 - reCaptcha 8.3.0
Comment #5
sajid_007 commentedMethod 1
First simply install recaptcha module from here https://www.drupal.org/project/recaptcha or you can install it using git after that place this attached "google" folder inside vendor folder of your drupal directory it will fix your issue.
Method 2
Second method is you can just simply install recaptcha module using composer it will also fix your issue.
Comment #6
dskyo commentedSteps to reproduce on drupal 8.9
Add CAPTCHA module from https://www.drupal.org/project/captcha and install
Add reCAPTCHA module from https://www.drupal.org/project/recaptcha and install
Configure CAPTCHA to use reCAPTCHA as default
Add reCAPTCHA to some of the forms. For example login form or contact form
Try submitting the form as Anonymous
Comment #7
drupal.ninja03 commentedHi @dskyo,
I installed both the captcha & Recaptcha modules and enabled it for the login form. I was able to use the Recaptcha on the login form successfully without any such error.
Drupal 8.8.9, PHP 7.2, Captcha 8.x-1.1, ReCaptcha 8.x-3.x
Comment #8
kaaa commentedAs far as I can see, a bunch of require_once directives is missing in ReCaptcha 8.x-3.x in recaptcha.module in the very preamble of the file (comparing to ReCaptcha 8.x-2.5):
require_once dirname(__FILE__) . '/recaptcha-php/src/ReCaptcha/ReCaptcha.php';
require_once dirname(__FILE__) . '/recaptcha-php/src/ReCaptcha/RequestMethod.php';
require_once dirname(__FILE__) . '/recaptcha-php/src/ReCaptcha/RequestParameters.php';
require_once dirname(__FILE__) . '/recaptcha-php/src/ReCaptcha/Response.php';
require_once dirname(__FILE__) . '/src/ReCaptcha/RequestMethod/Drupal8Post.php';
Adding those directives solves the problem.
Comment #9
bamlhes commented#5 worked for me by ( second method ) composer , thanks .
Comment #10
jeffc518 commentedSame issue here - Drupal v8.8.2, PHP 7.3, Webform 8.x-5.12
I'm looking at line 162 of recaptcha.module:
I can't actually find a "ReCaptcha" class, my IDE complains about it (Undefined class). This site is on Pantheon with their standard one click update upstream so it's not something I'm managing with Composer. Any other patches in the works? : )
Comment #11
jeffc518 commentedFYI, I found this SO answer helpful to get some more context on the other answers here: https://stackoverflow.com/questions/29056472/google-recaptcha-2-fatal-er...
As much as I'd like to be using Composer, I wasn't given the option with this project so I need to take an extra step and download the Recaptcha library separately. If anyone has a better option though please let me know.
Comment #12
jacob.herrera commentedFor anyone who doesn't have access to composer and needs a quick fix, I was able to get my reCaptcha working again by:
I was able to successfully submit forms with reCaptcha enabled again, but I'm sure there's a more correct fix for those without composer out there somewhere.
Comment #13
ahmed.raza commentedThere should be a correct fix for this who install modules via drush. Getting this exact same issue again on a new Drupal project.
Comment #14
huntertrammell commentedI can confirm #12 worked for me, I also did not have access to composer and ran into the same error! Using Drupal 8.7.6 with module ver 8x-3.0
Comment #15
estoyanov commentedI can confirm #12 worked for me as well, I am using Drupal 9.0.3 with module version 8x-3.0.
Comment #16
MikheevDesign commentedI can confirm #12 worked for me as well, I am using Drupal 9.0.6 with module version 8x-3.0.
Comment #17
ferst commentedI can confirm #12 worked for me as well, I'm using Drupal 9.0.6 with ReCaptcha 8.x-3.0.
Comment #18
countach commented#12 doesn't work for me - it's possible to submit the form without checking the captcha :(
//update - sorry, I forgot to upload the google dir into vendor dir :P It does work!
Comment #19
froboyI ran into a similar issue, running into failing forms and
Error: Class 'ReCaptcha\RequestMethod\Drupal8Post' not foundin my logs.I was able to resolve the issue by changing the
usestatement in my custom module:I haven't dug in, but it seems like this is just the result of some namespace changes or maybe the new use of composer in the move from 2.x to 3.x.
Comment #20
deslack commentedI can confirm #12 also worked for me, fixing the same error. Since i'm on a shared host, composer was unavailable to me. Using Drupal 8.9.8 with module ver 8.x-3.0
Comment #21
mylocaltrades commentedI can also confirm that #12 worked for me, fixing the same error. Using composer didn't resolve this issue for me on a number of sites. This was using Drupal 8.9.10 with module version 8.x-3.0
Comment #22
RazedandRisen commentedI have the same error and have tried the solution in #5 and still get Error:
Class 'ReCaptcha\ReCaptcha' not found in _recaptcha_v3_verify_captcha_response() (line 287 of modules/recaptcha_v3/recaptcha_v3.module).
My ReCaptcha folder does not have another ReCaptcha inside it. So I'd imagine since I don't have this structure "ReCaptcha\ReCaptcha" is why I'm getting this error.
I've downloaded the latest version of ReCaptcha from the drupal mod site and installed it through the "Extend" tab in the admin.
Am I missing something?
Drupal 9.1.0 and php version 7.3.15
Comment #23
lomale@bluewin.ch commentedI had the same problem. Same log error
Running Drupal-Version 8.9.12 PHP 7.4.13
reCAPTCHA V3
I can confirm #5
Method 2
Second method is you can just simply install recaptcha module using composer it will also fix your issue.
without having to add the 5 lines of
#8
Thanks for the help on this page.
Comment #24
aritrika.d commentedComment #25
aritrika.d commentedComment #26
reis quarteu commentedI can confirm #12 worked for me as well, I am using Drupal 8.9.13, PHP 7.3.26, with module version 8.x-3.0.
However, I have tested and am pretty sure that the step #1 (unzipping the zip in #5 into my vendor folder) is not necessary: I have removed it from my web site, and the reCaptcha is working nicely.
Comment #27
lubwn commentedInstalling 8-2.5 with attached patch from #24 solves an issue for me. I think version 3.0 should not be reccomended if it does not work out of the box.
Comment #28
cameroncrobinson commented#8/#24 only work if you include the recaptcha-php folder which has been removed from the 3.x build of recaptcha. After adding that folder back recaptcha seems to be working fine (as stated in #12). And those require_once directives. What was supposed to be the replacement functionality for that folder?
Comment #29
KLIGGS commented#5 and #24 worked for me with D8.9.13, PHP 7.4.13, recaptcha 8.x-3.0
Steps
Copy this lines on top of file /modules/recaptcha/recaptcha.module, if manually editing.
Comment #30
isalmanhaider commented#29 worked for me!
Great explanation
Comment #31
cangurin limpiezasThanks #29 worked for me too in Drupal 9.1.4!
Comment #32
sajithathukorala commented#29 worked but now form can submit without captcha . any idea ? this is tested for webforms .
Comment #33
thomaswalther commentedI got this error on drupal 8.8.5.
Comment #34
luison commentedThis is still an error. Fixed with #12 solution.
Comment #35
drupalfan2 commentedI installed the recaptcha module with composer, but I still get this error:
Error: Class 'ReCaptcha\ReCaptcha' not found in recaptcha_captcha_validation() (line 162 of modules/contrib/recaptcha/recaptcha.module).google/recaptcha has been installed to vendor dir by composer, but the error still is here.
Please commit a working patch!
Comment #36
drupalfan2 commentedI added the following code lines to top of recaptcha.module to get it work:
vendor/google/recaptcha has been installed by composer, but why it is not autoloaded????
Comment #37
chris matthews commentedComment #38
aswathyajish commentedI have tried #5 and #29, but no results. After applying patch, when tried to clear cache, site breaks.
Comment #39
joshuautley commentedDuplicate. Solved using Ludwig.
Ref > https://www.drupal.org/project/recaptcha/issues/3152474
Comment #40
drupalfan2 commentedWe need a solution without any patch for 8.x-3.1!
It is high time for a new release.
Comment #41
devad commentedThere is a working patch in related issue.
Review it and try to convince reCAPTCHA maintainers for commit.
Ludwig integration is the optimal way to add support for Drupal users not familiar with Composer yet. If reCAPTCHA maintainers would like to support any other method of course.
Ludwig is created and maintained by Drupal Commerce team to solve all kinds of "How can I use this module without Composer?" issues. Other approaches (Patch #24 and similar) are not recommended in D8/9.
Comment #42
drupalfan2 commentedI think we need a solution that works with composer.
What is actually the problem? Why isn't the module and its dependencies installed correctly?
Comment #43
gumdal commentedBeen a year since #12 was proposed, still that is the only solution for me. Moreover, composer will not work unless we have terminal access but in shared hosting environment we rarely get the terminal access. Drupal needs to consider solutions for non-composer users!
Comment #44
drupalfan2 commentedI think this is NOT a ludwig problem.
Comment #45
webdevfreak commentedThis issue is still active in Drupal 9 and need fixing. I have tried both options i.e composer and ludwig but no luck.
reCAPTCHA Version: 8.x-3.0
Drupal Version: 9.1.4
PHP Version: 7.4.21
Error message:
"The website encountered an unexpected error. Please try again later.
Error: Class 'ReCaptcha\ReCaptcha' not found in recaptcha_captcha_validation() (line 164 of modules/contrib/recaptcha/recaptcha.module)."
Comment #46
dcrellen commentedI stumbled upon this page after fighting this issue for 2 days. In my Drupal 9 I finally bit the bullet, learned how to use Composer (https://www.drupal.org/docs/8/modules/recaptcha-v3/installation-and-conf...) and used this command: composer require drupal/recaptcha_v3
That, magically made it all work!!!
The Recaptcha project page needs to EMPHASIZE the need to use composer to make it work.
Thanks to all for their efforts/pains
Comment #47
devad commentedRe: #46
Just in case you are not aware of... the drupal/recaptcha_v3 is a completely different Drupal module/project. This issue queue is for drupal/recaptcha module.
Comment #48
buddym commentedFollowing steps 2 & 3 from #12 resolved the "Error: Class 'ReCaptcha\ReCaptcha' not found in recaptcha_captcha_validation()" on Drupal 9.2.4 with CAPTCHA 8.x-1.2 and reCAPTCHA 8.x-3.0.
Comment #49
drupaleye commentedThis worked for me (recaptcha 8.x-3.0 and Drupal 9.2.6):
Voila! I officially love the Ludwig module now. Thanks devad!
Comment #50
devad commentedThere is the automatic "Download and unpack missing packages" button at the top of Ludwig's Reports / Packages page. This button takes care of cache clear as well.
Note: If you are using Ludwig version prior to 8.x-1.4 it does not have the automatic "Download and unpack missing packages" button. So, update to the latest one.
There are a lot of outdated Ludwig tutorials on WEB who are explaining the manual library setup steps. But the manual download and unpack of missing packages is not needed any more. Unless your server is not allowed to connect to external links.
Read more here:
Manual library setup [obsolete]
Comment #51
promo-il commented+1
Comment #52
jeeba commented#49 works for me. And also it should be suggested in the Recaptcha Module that installing the library is needed. It will help a lot with this.
Comment #53
Jean Gionet commented#49 did the trick! Thanks!
Comment #54
Greg Sims commented#49 worked for me on Drupal core 8.9.20.
Please note getting past this error is required for us to upgrade to Drupal 9. I would think many people are seeing this error.
Comment #55
bas123 commentedI just upgraded to Drupal 9.3.2 and realized the Site Login reCaptcha is throwing this error:
Drupal v 9.3.2 | PHP v 8.1 | reCaptcha v 8.x-3.0
I see several solutions here, but none seem to address Drupal ^9
I have temporarily switched default Captcha settings to "Image (from module image captcha)" and the process is working, but not when the default is set to reCaptcha!
Please advise!
Thanks!
Comment #56
kazaa commentedin Drupal 9 fix not working, still I have notice "The website encountered an unexpected error. Please try again later."
When I am logged to my profile in Durpal is ok, but for not logged users this communicate is visible after captacha approve.
Drupal core 9.1.10
Comment #57
devad commentedI can not reproduce this on clean Composer-managed D9.3.3 installation with recaptcha 8.x-3.0 or the latest 8.x-3.x-dev.
If you can reproduce the '
Class "ReCaptcha\ReCaptcha" not found' error please post the exact steps to reproduce this error.And in your post with reproducing steps also please post all of the following data:
requiresection of your composer.json file have this line of code:"drupal/recaptcha": "^3.0",. If it doesn't have it - please read post #61 below.The screenshots of your "CAPTCHA settings", "Form settings" and "reCAPTCHA" settings can help as well. You can hide the recaptcha keys at your screenshot of course.
Comment #58
bas123 commented@devad,
composer.json:
Comment #59
devad commentedRe: @bas123 #58.
Thank you for report.
There is no such thing as reCaptcha Version: 8.x-1.2 among the reCaptcha releases.
reCaptcha branches: 8.x-1.x and 8.x-2.x are not supported any more.
You need to install reCaptcha version 8.x-3.0 with composer:
composer require 'drupal/recaptcha:^3.0'
after that, your composer.json file will also have this line:
and your "Class 'ReCaptcha\ReCaptcha' not found" error should be fixed.
Please, try and reply back the result.
Comment #60
caspervoogt commentedComposer-managed Drupal 9.3.3 here, and running into this with ReCaptcha 3.0 and 3.x-dev. Hosted, PHP 7.4. No Ludwig.
Composer.json:
Captcha version 1.2, ReCaptcha version 3.0 / 3.x-dev (tried both).
Error:
User: Anonymous
Location: https://mysite.com/dlt-assessment?_wrapper_format=drupal_ajax&ajax_form=1
Referrer: https://mysite.com/dlt-assessment?page=public_sector_infrastructure
Severity: Error
Comment #61
devad commentedRe: #60
It is visible from your
composer.jsonfile that you do not have drupal/recaptcha module installed by composer.You need to install reCaptcha version 8.x-3.0 with composer command:
composer require 'drupal/recaptcha:^3.0'after that, your composer.json file will also have this line:
and your "Class 'ReCaptcha\ReCaptcha' not found" error should be fixed.
Please, try and reply back the result.
Changing the status of this issue to "Normal" & "Support Request" until somebody provides valid steps to reproduce the error with proper Composer installation.
Comment #62
caspervoogt commentedMy mistake; I just pasted the wrong composer.json. I *was* using ReCaptcha but had switched to hCaptcha because ReCaptcha kept returning an Ajax error. The steps in my previous post still stand.
I am running Drupal 9.3.3. Here are my steps, which I just ran through once more just to make extra sure what I reported was correct:
Comment #63
asdinnie commentedHi
I am running Drupal 9.3.7 with reCAPTCHA 8.x-3.0.
Cannot use Composer as we are running our site on shared hosting. So reCAPTCHA was installed from within Drupal.
The reCAPTCHA worked fine until recently (I think!) until I did a minor upgrade to Drupal (from 9.3.4 to 9.3.7).
Now I get the error described above:
Error: Class 'ReCaptcha\ReCaptcha' not found in recaptcha_captcha_validation() (line 162 of /home/public_html/web/modules/contrib/recaptcha/recaptcha.module)Is there an easy way around this problem now (given the plethora of fixes above) without using Composer?
I am not really a coder, more a site builder!
Many thanks,
God Bless
Andrew
Comment #64
devad commentedRe: #63
The solution (Ludwig patch) is here: #3152474: reCAPTCHA - Ludwig integration
Comment #65
asdinnie commentedHi devad
Thanks for your reply.
Apologies for the delay in responding. I have been out of action...
Have installed Ludwig, added the json file and the reCAPTCHA now works a treat. Very pleased!
Have been getting spam with the basic captcha so this will make life easier for me as well.
Would like the option for "tick the box only" though. I get the "pick the right box" quiz each time when testing my forms.
Many thanks for your help and maintenance of Ludwig. Much appreciated.
One last question please:
I presume (?) I do my various module updates as per normal when required, or do I need to check Ludwig as well?
Many thanks again.
God Bless
Andrew
Comment #66
devad commentedThanks. Welcome.
Here is the guide you should follow during the updates:
Maintenance of Ludwig managed modules
Comment #67
ahmed.raza commentedStill getting the same error after installing the update v8.x-3.0
Comment #68
devad commentedRe: $67.
Please post the following data for debug purpose:
Comment #69
bas123 commenteddevad,
Thank you for the specific correction!
I had reported the incorrect installation of reCaptcha (in #58 above) in my last post, as it was in fact Version: 8.x-3.0, however as it was indeed not registered as required in the composer.json, it must have been maintained and updated via the UI from it's original installation.
As the Developers of the theme (More Than Themes) the site is based on, who released it several years ago under Drupal 8 seemed to be slow in adopting Composer run installations. I had moved it entirely when I updated the site to Drupal 9, but had always updated modules in the UI when Drupal reported new versions.
Anyway, I added it via 'composer require', and the error is resolved!
Now I must wonder which other add-on modules I have running that might encounter this sort of issue going forward.
May I ask if there is anyway to sniff the potential for this sort of problems in advance short of adding each and every added module into the composer.json as a required dependency?
Thanks!
Comment #70
devad commentedRe: #69
You are welcome @bas123
I am not aware of such sniff tool. You can continue to manage all modules without library dependencies with UI of course. But it is best to add all your modules with composer. It is very easy to add them all. And if any of these modules will add some library dependency in its future release you will be safe since composer will recognize and include the new dependency automatically.
Comment #71
devad commentedRe: #60, #62
@caspervoogt Can you try to reproduce the same error on clean D9 installation and reply back if the error is still there?
Comment #72
mfh commentedI have the same issue in Drupal 9.4.1:
I can't use composer nor drush because my hosting plan provides only FTP and MySQLadmin, but no CLI access.
Comment #73
joshuautley commented#5 > Method 2 (and I had to delete the old module dir which was outside the contrib dir - because new installs are configured within the composer.json file to install into contrib).
Comment #74
devad commentedRe: #72
You can build and maintain your site locally with Composer and upload it via FTP.
Or you can try D8/9/10 alternative to Composer - Ludwig. #3152474: reCAPTCHA - Ludwig integration
Comment #75
Metztli commentedCame across error subject when I upgraded recaptcha to 8.x-3.1 in Drupal 9.4.8.
I try to avoid tools, i.e., drush, etc., as I manually had been updating modules and Drupal itself since version 6.x.y; accordingly I had not used composer --until now. Composer fixed the error of the thread topic; nothing else worked.
Comment #76
dalpasso commentedVariation of #5 and #24 worked for me with D9.5.10, recaptcha 8.x-3.2:
Added these lines to recaptcha.module after the last use statement:
require_once dirname(__FILE__) . '/src/ReCaptcha/ReCaptcha.php';
require_once dirname(__FILE__) . '/src/ReCaptcha/RequestMethod.php';
require_once dirname(__FILE__) . '/src/ReCaptcha/RequestParameters.php';
require_once dirname(__FILE__) . '/src/ReCaptcha/Response.php';
Copied these class files from version: v8.x-3.1 of the module into recaptcha/src/ReCaptcha/
Comment #77
lubwn commentedSolution from #61 worked for me. Installing with composer command solved the issue:
composer require 'drupal/recaptcha:^3.0'I have older Drupal 8.9.x website where update would be problematic so I installed recaptcha at first by hand, but came across this error.
I duplicated composer.json file somewhere locally, run the command, copied vendor directory to live website and it started to work.
Comment #78
dianacastillo commentedthe solution in #76 worked for me , added the google directory into vendor directory and then added those lines to the recaptcha module as well as the files he includes in the zip to the src/recaptcha directory
Comment #79
idas commentedSame error for me with Drupal 10 and the latest version of this module.
You must necessarily install it with composer and work.
Comment #80
devad commentedRE: #79
The Ludwig integration is added recently, so the latest 8.x-3.x-dev can be installed with Ludwig as well. The next 8.x-3.3 release will be Ludwig friendly as well.
Of course, please note that the Composer is highly recommended whenever possible!
I believe this issue can be closed as outdated. If you have a proper Composer installation (or the proper Ludwig + reCAPTHA 8.x-3.x-dev installation) and you experience this issue still - please feel free to reopen.
Comment #81
asdinnie commentedHi
The error in forms has now reappeared when a non-authorised user submits a form.
Just upgraded to ReCaptcha 8.x-3.4 under Drupal 10.3.2
Running Ludwig 2.0.7 & CAPTCHA 8.x-1.15
I am still installing modules via Drupal...
Will have to upgrade to Composer sometime but it's a major pain as it's a shared server (home directory cannot be changed, etc.).
The following error whenever a form is submitted:
Error: Interface "ReCaptcha\RequestMethod" not found in include() (line 13 of /home/progres1/public_html/modules/recaptcha/src/ReCaptcha/RequestMethod/Drupal8Post.php).The original lines in ludwig.json are present:
Ludwig Packages tells me that google/recaptcha is downloaded.
Have I missed something?
Many thanks,
Andrew
Comment #82
alex oliver perez commentedSolution in #76 worked for me with Drupal core 10.3.2 and reCAPTCHA 8.x-3.4
Comment #83
asdinnie commentedHi Alex
Thanks very for the note.
It now works!
Pity it doesn't stay like that after each upgrade...
Much appreciated,
Andrew
Comment #84
devad commentedRe: #81+
The patch #2 in the newly added related issue should fix issue described in comment #81. Please test and reply.