-
-
Notifications
You must be signed in to change notification settings - Fork 505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throw deprecation warning on nested flushes #1647
Conversation
$this->orphanRemovals = | ||
$this->hasScheduledCollections = array(); | ||
} finally { | ||
$this->commitsInProgress--; |
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.
We should have a test checking that commitsInProgress
is decreased in case of exception or any error.
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.
Test added.
Looking at #1584, the suggestion is to also deprecate calls to other persistence methods ( |
I think it will require a lot of ifology as for instance it is safe to call |
Which is exactly why I wouldn't allow any events at all after |
While this is a noble thing to do, this also takes away feature that is quite powerful and working without side effects (to some degree of course) :P I mean I can see people wanting to remove a document after successful update of another one, and if somebody is caring enough to go look into UoW's internals to figure out it's OK to do so, I'm happy for them. |
That's a valid use case, although I think people should be handling this in Furthermore, even by looking into UnitOfWork, scheduling a new operation while the flush is in progress is a big no-go as you can't be sure it will be executed (for one, order of operations may forbid it or we may ignore it because we already handled insertions for that type, etc.). |
Merging without additional deprecations - we can always re-visit this. Ideally we'll find a different solution to the problem at hand. |
As indicated in #1051, calling
flush
in an event subscriber can have unwanted side effects and shouldn't be done. To prepare people for this change, ODM 1.2 will throw deprecation warnings to give users a chance to fix offending event subscribers before 2.0 starts throwing exceptions.