Details
Description
When FLOW3 maps request arguments to entities, it works on clones of the changed entities while entities, which are not affected by the request arguments stay the original objects. If the entity has a persistent collection which is not changed and therefore not cloned, the call to $repository->update() (which internally calls $em->merge()) eventually clears the $managedCol in $uow->doMerge() (line 1460 in current master), but if the $mergeCol is the same object, this is obviously wrong behavior as no related entities exist anymore in the entity to merge.
Made up example code (not sure if this simple example works as I have no test setup I could use for it)
/**
* @entity
* @scope prototype
*/
class A {}
/**
* @entity
* @scope prototype
*/
class B {
/**
* @var \Doctrine\Common\Collection\ArrayCollection<A>
* @ManyToMany
*/
public $relation;
}
$b = $repository->find(); // assume $b has some A in relation
$anotherB = clone $b;
$em->merge($anotherB);
After this relation of $b is empty
Activity
Benjamin Eberlei
made changes -
| Field | Original Value | New Value |
|---|---|---|
| Status | Open [ 1 ] | Resolved [ 5 ] |
| Fix Version/s | 2.0.7 [ 10150 ] | |
| Fix Version/s | 2.1.1 [ 10153 ] | |
| Resolution | Fixed [ 1 ] |
Benjamin Eberlei
made changes -
| Workflow | jira [ 12824 ] | jira-feedback [ 14951 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback [ 14951 ] | jira-feedback2 [ 16815 ] |
Benjamin Eberlei
made changes -
| Workflow | jira-feedback2 [ 16815 ] | jira-feedback3 [ 19068 ] |