[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    


cascadeRemove incorrect work


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);



in array we get


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

if move cascadeRemove after switch all woork correct

Comment by Ivan Borzenkov [ 01/Nov/12 ]


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 Fri Oct 09 12:18:31 EDT 2015 using JIRA 6.4.10#64025-sha1:5b8b74079161cd76a20ab66dda52747ee6701bd6.