Skip to content
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

Fix merging of documents when not cascading references #2108

Merged
merged 1 commit into from
Nov 13, 2019

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Nov 12, 2019

Q A
Type bug
BC Break no
Fixed issues Fixes #2106

Summary

The described issue only appears when not cascading merge operations. The problem is that the call to registerManaged after creating a new proxy object will return early since a document with that ID is already registered (the original proxy loaded in $managedCopy. This leads to the new value for the association being different from the document that is being managed by the entity manager, which again causes issues on subsequent proxy initialisations.

On a related note, I'm not sure why the merge logic includes creating a new proxy object for the managed copy and discarding the changes from the original. However, this is logic that was introduced 8 years ago to ORM, was ported to MongoDB ODM and wasn't changed in ORM since, so I don't feel comfortable changing this particular thing about it.

@alcaeus alcaeus added the Bug label Nov 12, 2019
@alcaeus alcaeus added this to the 1.3.4 milestone Nov 12, 2019
@alcaeus alcaeus self-assigned this Nov 12, 2019
@alcaeus alcaeus added this to 1.3 (bug fixes only) in Roadmap Nov 12, 2019
@alcaeus alcaeus requested a review from malarzm November 12, 2019 13:24
@malarzm
Copy link
Member

malarzm commented Nov 12, 2019

On a related note, I'm not sure why the merge logic includes creating a new proxy object for the managed copy and discarding the changes from the original.

I believe the merge logic is "take everything as I present you and consider it your state as it was read from db" hence, I believe, discarding of original document state as the merge is cascaded.

@malarzm
Copy link
Member

malarzm commented Nov 12, 2019

Please disregard my previous comment, I should have first read the code and where the discard/create is located :)

Copy link
Member

@malarzm malarzm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code/decision looks strange but I'm not gonna argue with an 8 years old ORM change. Code itself looks OK and is tested so 👍

@alcaeus alcaeus merged commit 8cf8fa0 into doctrine:1.3.x Nov 13, 2019
@alcaeus alcaeus deleted the gh-2106 branch November 13, 2019 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Roadmap
1.3 (unsupported)
Development

Successfully merging this pull request may close these issues.

None yet

2 participants