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

Undefined array key "score" #65

Closed
bohacf opened this issue Jan 12, 2024 · 3 comments
Closed

Undefined array key "score" #65

bohacf opened this issue Jan 12, 2024 · 3 comments

Comments

@bohacf
Copy link

bohacf commented Jan 12, 2024

After updating to version 4.0.1, PHP throws this warning:

PHP Warning: Undefined array key "score" in .../vendor/contributte/recaptcha/src/ReCaptchaProvider.php:66

return $answer['success'] === true && $answer['score'] >= $this->minimalScore ? new ReCaptchaResponse(true) : new ReCaptchaResponse(false, $answer['error-codes'] ?? null);

@bohacf
Copy link
Author

bohacf commented Jan 13, 2024

I'm using the non-score version of reCaptcha 2. Here is a possible fix:

return $answer['success'] === true && ($this->minimalScore <= 0 || !isset($answer['score']) || $answer['score'] >= $this->minimalScore) ? new ReCaptchaResponse(true) : new ReCaptchaResponse(false, $answer['error-codes'] ?? null);

@f3l1x
Copy link
Member

f3l1x commented Jan 13, 2024

Let me know @bohacf. It's in master.

@bohacf
Copy link
Author

bohacf commented Jan 13, 2024

ReCaptchaProvider.php from master works fine. Thanks for the fix @f3l1x :)

f3l1x added a commit that referenced this issue Jan 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants