Issue with Doctrine 1.x: How to Delete Important Data

Issue with Doctrine 1.x

Issue with Doctrine 1.x: How to Delete Important Data

Oct 5, 2016 – 1 min read


A couple of months ago I had a bug issue with Doctrine 1.x which completely smashed my brain! If you use WhereIn() and pass an empty array as a second parameter the condition will be always “true”. Take a look at the code below:

It turns out that when we pass an empty array, Doctrine 1.x thinks about it as “all records in table VeryImportantTable” which in our case means “delete all records from table VeryImportantTable”.

That seams to be a huge bug issue because if we miss to check the content of the array we may accidentally delete very important information from our database. A simple workaround might be:

Pay attention when writing code and using Doctrine 1.x. Special thanks to my business partner Lyubomir Slavilov. We found the issue during our work.

If you need assistance with Symfony and Doctrine, contact me.

Whenever you're ready, here's how I can help you:

1. Develop your Product: Want to start, maintain, and grow your tech business? Our team of senior software engineers at Camplight can help.

A team of +50 employee members and +1500 pre-vetted experts. We have delivered 300+ projects, handled 1200+ consultation requests, gained expertise in 4 key industries. We can manage budget scopes ranging from $1k to $800k+.

​Read more


Contact Camplight