-
Notifications
You must be signed in to change notification settings - Fork 11.2k
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
[L6] Route URL Generation fails when giving 0 as a Route Parmater Value #30760
Comments
Why would your post id be 0? |
While it is unconventional, ids are typically unsigned integers. 0 is a valid id. In one particular case, I have users that may or may not have accounts. An external service always attempts to load the user's account balance and doesn't handle |
Yes that's true. I think this might be an easy fix to just check if it's |
Funny I didn't use |
Sent in a fix here: #30768 |
We did a new patch release with this fix. |
Description:
It appears when passing through an integer 0 (or any falsey value) to the route() helper or any other route URL generation function, a UrlGenerationException is thrown.
It appears this issue is caused by the following change in this PR: https://github.com/laravel/framework/pull/30714/files#diff-9ffa9921c8542da8cb0059fcbc3ad48aR218-R231
Since this is doing a non-strict type check on the Route Parameter value, it always returns false when any falsey value is given to it (as a blank string is equal to false in non-strict checks)
Steps To Reproduce:
Route::get('/user/{id}/post/{post_id}', 'PostController@get')->name('user.post');
route('user.post', [ 'id' => 1, 'post_id' => 0 ]);
Missing required parameters for [Route: user.post] [URI: user/{id}/post/{post_id}]. (View: ...)
The text was updated successfully, but these errors were encountered: