Replies: 1 comment 3 replies
-
Wouldn't |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Using the
->delete($id)
method with an argument can be seriously dangerous. If your$id
argument happens to evaluate tonull
you can wipe out an entire table and any foreign key constrained data. The safest pattern is obviously to use awhere
constraint but even having this undocumented feature is just asking for trouble. I've come across a bunch of its usage in a project I've got involved with and have had removed all instances.With the nullsafe operator (https://wiki.php.net/rfc/nullsafe_operator) added in PHP 8, this seems like something that is likely to catch a lot of people out.
It would be good to remove this feature in future versions of Laravel and highlight how dangerous it is to currently use in the documentation. It should be a simple
delete()
without any arguments.Beta Was this translation helpful? Give feedback.
All reactions