-
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
Route model binding behaviour changed in 9.14 #42513
Comments
@ksassnowski could this be because of your PR? #42425 @dwightwatson what happens if you revert those changes? Right now, there indeed is no documentation about this behavior for three params: https://laravel.com/docs/9.x/routing#implicit-model-binding-scoping |
Yeah, it works on Laravel 9.14.0 if I revert the changes from that PR. |
I get that my use-case is probably uncommon (will be interesting to see if it affects other people as well) so I'm not fussed if this becomes the new default behaviour. But perhaps a good opportunity to make a call on what should happen when dealing with more than 2 params. |
I have the same issue after upgrade to 9.14 |
This probably due to this line here https://github.com/laravel/framework/blob/9.x/src/Illuminate/Routing/ImplicitRouteBinding.php#L49 It checks if the parameter name exists in the route's binding field. Since my change made it so that if any of the parameters provides a custom binding field, every parameter gets added to the route's binding field (but possibly with |
I'll send a PR for this shortly. |
@driesvints Can you maybe point me to the tests that cover the |
Nevermind, I don't know why PhpStorm didn't find |
I've submitted a PR (#42517) that fixes this. I've also tested the changes against the repository provided by @dwightwatson and the tests pass again. |
Thanks for the quick turnaround @ksassnowski, champion! |
Description:
I've just discovered a breaking change that appeared between 9.13.0 and 9.14.0. I've got a complex use-case but I've tried to break it down. Here's the route set up that was working in 9.13.0.
The intention here is that the
campus
record is scoped to theinstitution
and that the category is not scoped to other route models. However, after upgrading to 9.14.0 it appears Laravel is also trying to scope the category to the campus and blowing up because the association does not exist:Totally appreciate if perhaps my mixed use of nested routing and non-nested routing is unintended behaviour and that this is actually a fix, but thought it was worth bringing up. I'll roll back to 9.13.0 in the meantime.
Steps To Reproduce:
I have created a repo here: https://github.com/dwightwatson/routing-bug
If you pull it down and run
php artisan test
it should pass using the SQLite database. If you opencomposer.json
and bump to Laravel 9.14.0 and re-run the tests it should fail.The text was updated successfully, but these errors were encountered: