-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
RateLimiter attempt method returns true if callback returns values considered false #44820
Comments
Heya, this is the expected behavior. The callback isn't a mechanism to control wether a message should be sent or not. It's the callback that sends the message. What you return in the callback is up to you and it returns true by default. |
I believe the API was specifically designed to return a truthy value because |
This breaking update allows users to control return values explicitly without converting to bool.
* Fix RateLimiter callback return substitution (#44820) This breaking update allows users to control return values explicitly without converting to bool. * Update RateLimiter.php Co-authored-by: Taylor Otwell <taylor@laravel.com>
Description:
The
attempt
method contains?:
operator and casts the return value of$callback
function totrue
for all list of values considered as false.Steps To Reproduce:
Obviously, it's a bug, but the fix also affects the
attempt()
method return value and may bring backward incompatibility to those who depend ontrue
return.I believe we have to change attempt() body, remove the cast:
and return explicitly defined user value
$callback()
Case: 3rd-party APIs may return empty arrays as a successful response.
I'm ready to provide PR but kindly ask the community to advise how to deal with this bug-fix effect.
Does it make sense to push the fix in the next version branch?
The text was updated successfully, but these errors were encountered: