recaptcha
recaptcha copied to clipboard
PHP 8.1 deprecations
Issue description
PHP 8.1 deprecations are being triggered.
Deprecated: strcasecmp(): Passing null to parameter #2 ($string2) of type string is deprecated
In our case it happens, when we set expected action, but none is passed from client.
But there are other usages of strcasecmp, but we don't enter those program branches.
Environment
- PHP version: 8.1
-
google/recaptchaversion: 1.2.4, but it probably applies to older versions too
Reproducing the issue
$recaptcha = new ReCaptcha($secret);
$recaptcha->setExpectedAction($expectedAction);
$response = $recaptcha->verify($token);
Where $expectedAction is not null and $token was created by client without passing any action.
This example above hits the strcasecmp here:
https://github.com/google/recaptcha/blob/master/src/ReCaptcha/ReCaptcha.php#L176
There are other strcasecmp usages, just above this one, that could trigger the deprecation in a different setup I suppose.