-
-
Notifications
You must be signed in to change notification settings - Fork 504
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 more re-used embedded docs issues #1550
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -745,16 +745,6 @@ private function computeOrRecomputeChangeSet(ClassMetadata $class, $document, $r | |
if ($orgValue !== null) { | ||
$this->scheduleOrphanRemoval($orgValue); | ||
} | ||
|
||
if ($actualValue !== null) { | ||
list(, $knownParent, ) = $this->getParentAssociation($actualValue); | ||
if ($knownParent && $knownParent !== $document) { | ||
$actualValue = clone $actualValue; | ||
$class->setFieldValue($document, $class->fieldMappings[$propName]['fieldName'], $actualValue); | ||
$this->setOriginalDocumentProperty(spl_object_hash($document), $class->fieldMappings[$propName]['fieldName'], $actualValue); | ||
} | ||
} | ||
|
||
$changeSet[$propName] = array($orgValue, $actualValue); | ||
continue; | ||
} | ||
|
@@ -998,6 +988,10 @@ private function computeAssociationChanges($parentDocument, array $assoc, $value | |
if ($assoc['type'] === ClassMetadata::ONE) { | ||
$class->setFieldValue($parentDocument, $assoc['fieldName'], $entry); | ||
$this->setOriginalDocumentProperty(spl_object_hash($parentDocument), $assoc['fieldName'], $entry); | ||
$poid = spl_object_hash($parentDocument); | ||
if (isset($this->documentChangeSets[$poid][$assoc['fieldName']])) { | ||
$this->documentChangeSets[$poid][$assoc['fieldName']][1] = $entry; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This fixed #1542's failing test case and new one with early persist |
||
} | ||
} else { | ||
// must use unwrapped value to not trigger orphan removal | ||
$unwrappedValue[$key] = $entry; | ||
|
@@ -2193,6 +2187,11 @@ function ($assoc) { return $assoc['isCascadePersist']; } | |
} | ||
} elseif ($relatedDocuments !== null) { | ||
if ( ! empty($mapping['embedded'])) { | ||
list(, $knownParent, ) = $this->getParentAssociation($relatedDocuments); | ||
if ($knownParent && $knownParent !== $document) { | ||
$relatedDocuments = clone $relatedDocuments; | ||
$class->setFieldValue($document, $mapping['fieldName'], $relatedDocuments); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This however I fail to see why I need to bring back but without this change set test with late persist is failing for reason I don't see yet |
||
$this->setParentAssociation($relatedDocuments, $mapping, $document, $mapping['fieldName']); | ||
} | ||
$this->doPersist($relatedDocuments, $visited); | ||
|
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.
This is #1542 removed because it was good only for updates (it's in the path when document is not new) while one of tests I've added was interested in fixing inserts