Skip to content

Moved logic for scheduling orphanRemoval #1281

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 4 commits into from
Dec 14, 2015
Merged

Conversation

malarzm
Copy link
Member

@malarzm malarzm commented Nov 19, 2015

Supersedes #1278 and personally I like this one better. Also I was thinking if it's worth removing embedded documents out of orphan removal's interest but probably that would mean duplicating logic for cascading.

@malarzm malarzm added this to the 1.0.4 milestone Nov 19, 2015
@malarzm malarzm changed the title Poor orphans Moved logic for scheduling orphanRemoval Nov 19, 2015
@alcaeus
Copy link
Member

alcaeus commented Nov 21, 2015

👍 on this.

if ($topOrExistingDocument || CollectionHelper::usesSet($assoc['strategy'])) {
$this->scheduleCollectionUpdate($value);
}
$topmostOwner = $this->getOwningDocument($value->getOwner());
$this->visitedCollections[spl_object_hash($topmostOwner)][] = $value;
if ( ! empty($assoc['orphanRemoval']) || isset($assoc['embedded'])) {
$value->initialize();
Copy link
Member

Choose a reason for hiding this comment

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

Since both remove and set (which are the only methods that can remove elements) initialize the collection before making changes I'd argue that we could actually just skip uninitialized collections here. That could save a few seconds when having a large uninitialized collection sitting around.

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

For the record discussed behaviour was changed for a moment (malarzm#6) but as agreed on IRC it's not going to make it into ODM

malarzm added a commit that referenced this pull request Dec 14, 2015
Moved logic for scheduling orphanRemoval
@malarzm malarzm merged commit 3a014b3 into doctrine:1.0.x Dec 14, 2015
@malarzm malarzm deleted the poor-orphans branch December 14, 2015 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants