-
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
[9.x] Validate uuid before route binding query #44945
[9.x] Validate uuid before route binding query #44945
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea 👍
We might want to do the same for the ULID trait? |
I created it |
I don't think this properly addresses child route bindings. |
It looks like moving the check down to resolveRouteBindingQuery catches the child bindings as well. I updated the pull request. Let me know if you'd like to see any other changes. |
Don't you actually need to check and use the |
I'm sure you're right. I'll take another look at it. Thanks! |
$table->integer('user_id'); | ||
$table->timestamps(); | ||
}); | ||
|
||
$this->beforeApplicationDestroyed(function () { | ||
Schema::dropIfExists('users'); | ||
Schema::dropIfExists('posts'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the drop method of the table comments
in beforeApplicationDestroyed
This pull request overrides the resolveRouteBinding method in the HasUuids trait to ensure the given URI segment is a valid UUID before passing it to the database.
This check is necessary when using a Postgres database with the UUID datatype as passing anything other then a valid UUID will throw a QueryException. This check is also useful more generally to avoid unnecessary database queries.