-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Mention flush cannot be called inside postFlush
- Loading branch information
Showing
1 changed file
with
2 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @beberlei would you mind explaining why
flush()
cannot be called anymore ? I had a look at other commits in history, but did not find anything that seemed related to this one.It would be really useful for my use-case to be able to create and flush entities during a postFlush callback...
b6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can't flush in
flush
lifecycle events: it has never been supportedb6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The previous manual before this commit seems to say otherwise, and posts such as http://stackoverflow.com/a/16906067/37706 also seem to say it is possible. That's why I am confused.
Maybe I should re-formulate my question. My use-case is to create a log of (certain) entities modification. So AFAIK my requirements are a callback where:
That seems relatively common need, but I could not find an "official" recommendation on how to do that. I must say the documentation on events is hard to read, because there are a lot of information, not very well structure IMHO.
I tried with lifecycle on the entity class, but during preUpdate I could not create Log. I am now trying with a EventSubscriber and onFlush/postFlush events, but it's not successful yet either...
Any recommendations ?
b6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhhh, now I'm really confused, I ended up implementing a
flush()
in thepostFlush
event and everything is working fine. I doubled checked SQL generated and everything seems fine.And in-depth explanation of what may fail would really be appreciated.
b6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@PowerKiKi yes, it works, but it has never been officially supported, mainly because every second user applying this kind of logic falls into infinite recursion :-\
b6c3fc5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thanks for the explanation, luckily infinite recursion was easy to avoid in my case ;-)