For the purposes of the question I’ll ask about postUpdate
but I’m assuming they’re all analogous. If I fetch an existing entity, modify it, and then flush, then I can subscribe to a postUpdate
event about this. At the point that this event fires, is the data actually in the database yet? Or there a tiny amount of time in between the event firing and the data actually being saved still?
The docs seem to clearly say that
The postUpdate event occurs after the database update operations to entity data
so from that I’d assume the former.
But I’m encountering a problem similar to Symfony 2 postUpdate executed before data is stored – where the answer suggests that it’s because during a postUpdate
event the data is not actually fully saved yet, and that’s what the postFlush
event is for instead.
Can someone confirm either way please?
Advertisement
Answer
That behaviour occurs because all post* events are triggered inside transaction block (expect postFlush), so the datas are actually in the database already but they are in transaction which is not yet commited.