-
-
Notifications
You must be signed in to change notification settings - Fork 509
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
Conversation
👍 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(); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
set
doesn't really initialize collection when used: https://github.com/doctrine/mongodb-odm/pull/1281/files#diff-23b2d33965df3f6d7b558d98a301a34aL538
There was a problem hiding this comment.
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
b817f76
to
a2f78b7
Compare
a2f78b7
to
8e3f4ce
Compare
Moved logic for scheduling orphanRemoval
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.