Skip to content

Fix changeset handling for new documents #999

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

Closed
wants to merge 3 commits into from
Closed

Fix changeset handling for new documents #999

wants to merge 3 commits into from

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Dec 23, 2014

This fixes an issue that occurs when modifying a newly persisted document in an onFlush() event handler.
The issue causes the insertion to be treated as an update even though only an insert needs to be done. Thus, postUpdate listeners are called which is not correct.

Andreas Braun added 2 commits December 23, 2014 08:58
When changing a newly persisted document within onFlush(), recomputing the
changeset for this document will cause a documentUpdate to be created. As a
result, events will be triggered for persist and update at the same time, even
though only a persist happened.
@gruberro
Copy link

👍

@malarzm
Copy link
Member

malarzm commented Dec 24, 2014

@alcaeus it seems that your fix has broken some existing tests

@alcaeus
Copy link
Member Author

alcaeus commented Dec 24, 2014

Hmm, I guess I missed those. I'll fix them in the next couple of days.

@alcaeus alcaeus changed the title Fix changeset handling for new documents [WIP] Fix changeset handling for new documents Dec 24, 2014
@alcaeus
Copy link
Member Author

alcaeus commented Jan 8, 2015

I fixed the failing tests - however, considering they were written to test exactly the kind of behavior this PR aims at fixing, I'm not sure what the consequences would be. I'd really appreciate some feedback on this.

@malarzm
Copy link
Member

malarzm commented Jan 8, 2015

The test origin is #246 and I believe it was about detecting change in array, not sure if it was intended to trigger post update then or just used the fact that it does instead of checking change set... @jwage @jmikola @tecbot ?

@jmikola jmikola added the Bug label Feb 13, 2015
@alcaeus alcaeus changed the title [WIP] Fix changeset handling for new documents Fix changeset handling for new documents Feb 23, 2015
@alcaeus
Copy link
Member Author

alcaeus commented Feb 23, 2015

I've removed the WIP label since there was no feedback on the old tests.

@@ -803,7 +803,9 @@ private function computeOrRecomputeChangeSet(ClassMetadata $class, $document, $r
: $changeSet;

$this->originalDocumentData[$oid] = $actualData;
$this->documentUpdates[$oid] = $document;
if ( ! isset($this->documentInsertions[$oid])) {
Copy link
Member

Choose a reason for hiding this comment

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

Should we check $this->documentUpserts[$oid] as well here?

@jwage
Copy link
Member

jwage commented Mar 28, 2015

This is fixed in #782

@jwage jwage closed this Mar 28, 2015
@alcaeus
Copy link
Member Author

alcaeus commented Mar 28, 2015

@jwage Is #782 going to be merged anytime soon? It has been open for a while, and while I appreciate a good refactoring, sometimes I'd rather see bugs fixed, especially if they are hard to work around in software ;)

@jwage
Copy link
Member

jwage commented Mar 28, 2015

@alcaeus I understand, but I think patching the one off bugs here and there will end up making things much worse and harder or impossible to fix in the future without BC breaks. I finished the last known issues last night and got the tests passing. I need others to test the patch. I am going to be testing it against my application.

@alcaeus
Copy link
Member Author

alcaeus commented Mar 28, 2015 via email

@jwage
Copy link
Member

jwage commented Mar 28, 2015

@alcaeus Yes, I copied the test case over to my branch.

@alcaeus
Copy link
Member Author

alcaeus commented Mar 28, 2015

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants