Skip to content

Unschedule orphan removal if an element is re-added #1248

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

Merged
merged 3 commits into from
Oct 19, 2015
Merged

Unschedule orphan removal if an element is re-added #1248

merged 3 commits into from
Oct 19, 2015

Conversation

alcaeus
Copy link
Member

@alcaeus alcaeus commented Oct 15, 2015

This fixes a minor issue where removing an element from a PersistentCollection with orphanRemoval enabled and then re-adding it to the same collection leaves it scheduled for removal. This can produce invalid references.
This PR also fixes an issue where using set() in a PersistentCollection with orphanRemoval enabled would not remove an element that was overwritten and is no longer part of the collection.

@alcaeus alcaeus changed the title Unschedule orphan removal if an element is readded Unschedule orphan removal if an element is re-added Oct 15, 2015
@@ -551,6 +551,11 @@ public function add($value)
}
$this->coll->add($value);
$this->changed();

if ($this->uow !== null && $this->isOrphanRemovalEnabled()) {
Copy link
Member

Choose a reason for hiding this comment

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

Should same thing be done for set()?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. There was a bug that elements were not removed when being overwritten by set() - this is done properly now.

@alcaeus alcaeus added this to the 1.0.3 milestone Oct 19, 2015
alcaeus added a commit that referenced this pull request Oct 19, 2015
Unschedule orphan removal if an element is re-added to a PersistentCollection
@alcaeus alcaeus merged commit df14279 into doctrine:master Oct 19, 2015
@alcaeus alcaeus deleted the refmany-orphan-removal branch October 19, 2015 05:35
@malarzm
Copy link
Member

malarzm commented Nov 2, 2015

For the record @gabma's issue was resolved in #1256

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

Successfully merging this pull request may close these issues.

3 participants