DDC-2986: OrphanRemoval no longer works on OneToMany relationships after latest Symfony update - 2.3.10 #3712

Closed
opened 2026-01-22 14:25:59 +01:00 by admin · 14 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 18, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user dotlabel-scott:

Since release of Symfony version 2.3.10 the orphanRemoval feature in a doctrine entity no longer removes deleted entities.

Originally created by @doctrinebot on GitHub (Feb 18, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user dotlabel-scott: Since release of Symfony version 2.3.10 the orphanRemoval feature in a doctrine entity no longer removes deleted entities.
admin added the Bug label 2026-01-22 14:25:59 +01:00
admin closed this issue 2026-01-22 14:25:59 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

Needs a failing test case or better description

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: Needs a failing test case or better description
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

In Symfony version 2.3.9 when using an arrayCollection, if the items are removed from the arrayCollection then flushed the items are removed from the database.

Below are the mapped and inversed sides of the one to many relationship. When the Flush is carried out in Symfony 2.3.9 this works as expected although in 2.3.10 the items are not removed from the database.

    /**** 
     * @var ArrayCollection $dinnerMenuItems 
     * 
     * @ORM\OneToMany(targetEntity="DinnerMenuItem", mappedBy="dinnerMenu", cascade={"persist", "remove"}, orphanRemoval=true)
     * @ORM\OrderBy({"position" = "ASC"})
     */
    private $dinnerMenuItems;


    /**** 
     * @var DinnerMenu
     *
     * @ORM\ManyToOne(targetEntity="DinnerMenu", inversedBy="dinnerMenuItems")
     * @ORM\JoinColumn(name="menu_id", referencedColumnName="id")
     */
    private $dinnerMenu;

I originally opened this as a Symfony issue although they have just said it is a doctrine issue.

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: In Symfony version 2.3.9 when using an arrayCollection, if the items are removed from the arrayCollection then flushed the items are removed from the database. Below are the mapped and inversed sides of the one to many relationship. When the Flush is carried out in Symfony 2.3.9 this works as expected although in 2.3.10 the items are not removed from the database. ``` /**** * @var ArrayCollection $dinnerMenuItems * * @ORM\OneToMany(targetEntity="DinnerMenuItem", mappedBy="dinnerMenu", cascade={"persist", "remove"}, orphanRemoval=true) * @ORM\OrderBy({"position" = "ASC"}) */ private $dinnerMenuItems; /**** * @var DinnerMenu * * @ORM\ManyToOne(targetEntity="DinnerMenu", inversedBy="dinnerMenuItems") * @ORM\JoinColumn(name="menu_id", referencedColumnName="id") */ private $dinnerMenu; ``` I originally opened this as a Symfony issue although they have just said it is a doctrine issue.
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

This should be verified against doctrine ORM in insulation - "symfony 2.3.9" vs "symfony 2.3.10" doesn't make any difference for the ORM itself, since it is a different unrelated library.

You should probably reduce the scope of the search by looking at the diffs in your composer.lock file so that we can identify if there was a breakage, and where.

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: This should be verified against doctrine ORM in insulation - "symfony 2.3.9" vs "symfony 2.3.10" doesn't make any difference for the ORM itself, since it is a different unrelated library. You should probably reduce the scope of the search by looking at the diffs in your `composer.lock` file so that we can identify if there was a breakage, and where.
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

Below is the composer.lock diff. The only change is the Symfony version and this is the difference between it working and not working.

index 36e0cbf..a185179 100644
--- a/composer.lock
<ins></ins><ins> b/composer.lock
@@ -3,7 </ins>3,7 @@
         "This file locks the dependencies of your project to a known state",
         "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file"
     ],
-    "hash": "b674945e7d9bc77b57cfd87fd75c73a9",
<ins>    "hash": "340fb2e843409e3b13350e4697d3ebcc",
     "packages": [
         {
             "name": "doctrine/annotations",
@@ -3105,16 </ins>3105,16 @@
         },
         {
             "name": "symfony/symfony",
-            "version": "v2.3.10",
<ins>            "version": "v2.3.9",
             "source": {
                 "type": "git",
                 "url": "https://github.com/symfony/symfony.git",
-                "reference": "e4b9ff28b7c357971947ed12f99fbc68ff116830"
</ins>                "reference": "ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74"
             },
             "dist": {
                 "type": "zip",
-                "url": "https://api.github.com/repos/symfony/symfony/zipball/e4b9ff28b7c357971947ed12f99fbc68ff116830",
-                "reference": "e4b9ff28b7c357971947ed12f99fbc68ff116830",
<ins>                "url": "https://api.github.com/repos/symfony/symfony/zipball/ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74",
</ins>                "reference": "ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74",
                 "shasum": ""
             },
             "require": {
@@ -3211,7 <ins>3211,7 @@
             "keywords": [
                 "framework"
             ],
-            "time": "2014-02-12 08:18:23"
</ins>            "time": "2014-01-05 01:24:54"
         },
         {
             "name": "trsteel/ckeditor-bundle",
@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: Below is the composer.lock diff. The only change is the Symfony version and this is the difference between it working and not working. ``` index 36e0cbf..a185179 100644 --- a/composer.lock <ins></ins><ins> b/composer.lock @@ -3,7 </ins>3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "b674945e7d9bc77b57cfd87fd75c73a9", <ins> "hash": "340fb2e843409e3b13350e4697d3ebcc", "packages": [ { "name": "doctrine/annotations", @@ -3105,16 </ins>3105,16 @@ }, { "name": "symfony/symfony", - "version": "v2.3.10", <ins> "version": "v2.3.9", "source": { "type": "git", "url": "https://github.com/symfony/symfony.git", - "reference": "e4b9ff28b7c357971947ed12f99fbc68ff116830" </ins> "reference": "ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/symfony/zipball/e4b9ff28b7c357971947ed12f99fbc68ff116830", - "reference": "e4b9ff28b7c357971947ed12f99fbc68ff116830", <ins> "url": "https://api.github.com/repos/symfony/symfony/zipball/ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74", </ins> "reference": "ee1e0f2ef882ccd6a53ff91e5ffc39a22b6a6b74", "shasum": "" }, "require": { @@ -3211,7 <ins>3211,7 @@ "keywords": [ "framework" ], - "time": "2014-02-12 08:18:23" </ins> "time": "2014-01-05 01:24:54" }, { "name": "trsteel/ckeditor-bundle", ```
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

This seems to be only a symfony change - no upgrades/downgrades in doctrine packages?

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: This seems to be only a symfony change - no upgrades/downgrades in doctrine packages?
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

Yeah that's correct. That's what I tried to say on the Symfony issue but they closed it straight away. Something in the latest Symfony update has stopped the orphanRemoval annotation from working.

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: Yeah that's correct. That's what I tried to say on the Symfony issue but they closed it straight away. Something in the latest Symfony update has stopped the orphanRemoval annotation from working.
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

A fix has been committed to Symfony so this can be closed.

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: A fix has been committed to Symfony so this can be closed.
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

Issue was related to Symfony and is now fixed

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: Issue was related to Symfony and is now fixed
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

[~dotlabel-scott] reference to the commit?

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: [~dotlabel-scott] reference to the commit?
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by dotlabel-scott:

This commit fixed the issue - c4ffe02100

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by dotlabel-scott: This commit fixed the issue - https://github.com/symfony/symfony/commit/c4ffe02100eb6f4aaf92ad1ccecba1bf666b96fc
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

Not related to ORM

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: Not related to ORM
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Feb 18, 2014): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by @ocramius:

[~dotlabel-scott] thanks - changed resolution

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by @ocramius: [~dotlabel-scott] thanks - changed resolution
Author
Owner

@doctrinebot commented on GitHub (Feb 18, 2014):

Comment created by stof:

Yeah, the actual issue is indeed not related to the ORM at all. But the bug report was totally wrong (which is why I classified it as a Doctrine issue): the Symfony bug has nothing to do with orphanRemoval (it is not only the related entity which was not deleted. The element was not removed from the collection at all)

@doctrinebot commented on GitHub (Feb 18, 2014): Comment created by stof: Yeah, the actual issue is indeed not related to the ORM at all. But the bug report was totally wrong (which is why I classified it as a Doctrine issue): the Symfony bug has nothing to do with orphanRemoval (it is not only the related entity which was not deleted. The element was not removed from the collection at all)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3712