Skip to content

Loading…

DDC-2112: cascade remove revert order #2798

Closed
doctrinebot opened this Issue · 3 comments

2 participants

@doctrinebot

Jira issue originally created by user ivan1986:

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

@doctrinebot

Comment created by ivan1986:

patch

@doctrinebot

Comment created by ivan1986:


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

@doctrinebot

Issue was closed with resolution "Invalid"

@beberlei beberlei was assigned by doctrinebot
@doctrinebot doctrinebot closed this
@doctrinebot doctrinebot added the Bug label
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.