[DDC-2112] cascade remove revert order Created: 01/Nov/12  Updated: 08/Nov/12  Resolved: 08/Nov/12

Status: Resolved
Project: Doctrine 2 - ORM
Component/s: ORM
Affects Version/s: Git Master
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: Ivan Borzenkov Assignee: Benjamin Eberlei
Resolution: Invalid Votes: 0
Labels: None

Attachments: Text File DDC2112.patch    

 Description   

cascadeRemove incorrect work

UnitOfWork

in commit() (336)

// Entity deletions come last and need to be in reverse commit order
if ($this->entityDeletions) {
for ($count = count($commitOrder), $i = $count - 1; $i >= 0; --$i)

{ $this->executeDeletions($commitOrder[$i]); }

}

----------------------------------------------------------------
in doRemove (1630)

// Cascade first, because scheduleForDelete() removes the entity from the identity map, which
// can cause problems when a lazy proxy has to be initialized for the cascade operation.
$this->cascadeRemove($entity, $visited);

......

$this->scheduleForDelete($entity);

in array we get

child
child
parent

revert in commit - first remove parent and get foregein key error

if move cascadeRemove after switch all woork correct



 Comments   
Comment by Ivan Borzenkov [ 01/Nov/12 ]

patch

Comment by Ivan Borzenkov [ 01/Nov/12 ]

class Domain
{
...
    /**
     * @ORM\OneToMany(targetEntity="Query", mappedBy="domain", cascade={"all"})
     */
    protected $q;
...
}

class Query
{
...
    /**
     * @ORM\ManyToOne(targetEntity="Domain", inversedBy="q")
     */
    protected $domain;
...
}

if remove Domain - get mysql error foreign key

Generated at Sat Oct 25 17:42:31 UTC 2014 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.