Open kalifg opened 6 years ago
@kalifg , did you consider to use preFlush
event ?
@kalifg , did you consider to use preFlush event ?
Thank you for taking the time to respond! That's a great idea and I think it will work for us. Any onFlush
listener that does not depend on existing change sets should work just as well as a preFlush
.
I still think this issue needs to be resolved through at least some documentation of the phenomenon if nothing else. The difference in behavior between the two ORM states could be confusing.
Bug Report
Summary
If you call
flush()
when there are no changes (inserts, updates, deletes, etc) scheduled, no changes will be flushed — even if anonFlush
subscriber adds them.Current behavior
As described above, if you have an ORM with no registered changes, but you call
flush
expecting anonFlush
subscriber to create some changes, those changes will not be executed.The changes are registered with the ORM, and calling
flush()
a second time will execute them.This is because of the early exit here
How to reproduce
We have an
onFlush
subscriber that scans the identity map for entities of a certain interface. It then performs updates on some of them. It's code that is used to process a file upload on a form, sending it to S3 and then adding the S3 path to the entity.If the user doesn't change anything else in the form, the new S3 info will not be updated either (unless we use
flush()
twice). This code is paraphrased but I hope you get the idea.Expected behavior
I would expect one
flush()
to be sufficient; after dispatching theonFlush
eventUnitOfWork
could check the change arrays again to make sure they are still empty.,