Doctrine 2 preUpdate event

The doctrine project logo.

Some time ago I was implementing an event listener for Doctrine 2. While I was testing it I run into an issue where the events would not fire and I troubled me a great deal. More specifically, I would try to save my entities and events such as preUpdate would simply not seem to work.

The answer however could not be found in the documentation (maybe I just didn’t find it). Inside the function executeUpdates in of doctrine2/lib/Doctrine/ORM/UnitOfWork.php it says:

if (!empty($this->entityChangeSets[$oid])) {

This means that it looks for any changes to the model and if (and only if) there are any changes it will update the entity and trigger the event.

I opened a pull request for this which aim to clarify the documentation.