DDC-2112: cascade remove revert order #2656

Closed
opened 2026-01-22 13:59:29 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Nov 1, 2012).

Originally assigned to: @beberlei on GitHub.

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

Originally created by @doctrinebot on GitHub (Nov 1, 2012). Originally assigned to: @beberlei on GitHub. 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
admin added the Bug label 2026-01-22 13:59:29 +01:00
admin closed this issue 2026-01-22 13:59:29 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 1, 2012):

Comment created by ivan1986:

patch

@doctrinebot commented on GitHub (Nov 1, 2012): Comment created by ivan1986: patch
Author
Owner

@doctrinebot commented on GitHub (Nov 1, 2012):

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 commented on GitHub (Nov 1, 2012): 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
Author
Owner

@doctrinebot commented on GitHub (Nov 8, 2012):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Nov 8, 2012): Issue was closed with resolution "Invalid"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#2656