recaptcha icon indicating copy to clipboard operation
recaptcha copied to clipboard

PHP - 8.4 Deprecated Functionality: ReCaptcha\ReCaptcha::__construct()

Open pratikvs opened this issue 6 months ago • 2 comments

Hi,

This library does not support PHP8.4. The issue lies in the file g oogle/recaptcha/src/ReCaptcha/ReCaptcha.php where a ? should be addeed before the parameter RequestMethod $requestMethod = null in the second argument of the constructor. Please note the below patch for this.

`--- Patch/ReCaptcha.php 2025-05-26 11:53:22.470368105 +0530 +++ vendor/google/recaptcha/src/ReCaptcha/ReCaptcha.php 2025-05-22 16:12:51.219561321 +0530 @@ -136,7 +136,7 @@ * @param RequestMethod $requestMethod method used to send the request. Defaults to POST. * @throws \RuntimeException if $secret is invalid */

  • public function __construct($secret, ? RequestMethod $requestMethod = null)
  • public function __construct($secret, RequestMethod $requestMethod = null) { if (empty($secret)) { throw new \RuntimeException('No secret provided'); `

pratikvs avatar May 26 '25 07:05 pratikvs

A PR was submitted for this issue, but this library looks dead. Also Google is sunsetting this API at the end of 2025. Going forward you will be required to use the Enterprise version. Google is emailing upgrade info to everyone in the near future. In the meantime, if you want a PHP 8.4 compatible library, check out:

phpfui/recaptcha

Should be a drop in replacement. Just replace google with phpfui in your composer.json file and change the version to ^2.0.

Let me know of any issues.

phpfui avatar May 30 '25 15:05 phpfui

Duplicated of #565

garak avatar Jun 12 '25 07:06 garak

Solved in https://github.com/google/recaptcha/pull/575, this can be close

VincentLanglet avatar Jul 06 '25 15:07 VincentLanglet