-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
DDC-211: Exception is thrown after many calls to flush() #2796
Comments
Comment created by nicokaiser: The delete statement seems to come from \Doctrine\ORM\PersistentCollection#getDeleteDiff(), which returns the entities from the association that should be deleted (in this case this happens iff you delete associations between M:N entities): This is done by an *array_udiff($this->_snapshot, $this->_coll->toArray(), array($this, '_compareRecords'))*, where _compareRecords is nothing more than $a === $b. I modified getDeleteDiff() so it displays what it does and pasted the output here: http://pastie.org/744175 The full log with SQL is here http://pastie.org/744183 (here the Group has id 138 instead of 134). |
Comment created by romanb: array_udiff is very weird. If anyone can explain me this behavior, I would be delighted:
The array_udiff behavior is the reason for this problem. I just dont understand it. According to the manual: "Returns an array containing all the values of array1 ($snapshot in this case) that are not present in any of the other arguments. " |
Comment created by romanb: This should now be fixed. We're using array_udiff_assoc instead which behaves as expected and is faster. Also, this is a necessary preparation for DDC-213. This can now lead to join-table elements being deleted and reinserted when they change position in the collection, however this is expected and indeed needed for DDC-213. I don't see this as an issue for "unordered" collections. |
Issue was closed with resolution "Fixed" |
Jira issue originally created by user baumgartl:
Two classes having a many-to-many association:
Fill the database with some data:
After the user was added to the third group, an exception is thrown:
Using the EchoSqlLogger a strange SQL statement becomes visible (after the user was added to "group 3"):
Where does the delete statement come from? There is none of that in the code.
Interestingly the example works fine if the user is just added to three groups. If flush() is just called once at the end of the script, everything is fine too.
Many calls to flush() are expected to slow down execution time and/or increase memory consumption, but should work properly.
The text was updated successfully, but these errors were encountered: