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

Closed
doctrinebot opened this Issue Feb 18, 2014 · 14 comments

2 participants

@doctrinebot

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.

@doctrinebot

Comment created by @ocramius:

Needs a failing test case or better description

@doctrinebot

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

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

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

Comment created by @ocramius:

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

@doctrinebot

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

Comment created by dotlabel-scott:

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

@doctrinebot

Comment created by dotlabel-scott:

Issue was related to Symfony and is now fixed

@doctrinebot

Comment created by @ocramius:

[~dotlabel-scott] reference to the commit?

@doctrinebot

Comment created by dotlabel-scott:

This commit fixed the issue - symfony/symfony@c4ffe02

@doctrinebot

Comment created by @ocramius:

Not related to ORM

@doctrinebot

Issue was closed with resolution "Invalid"

@doctrinebot

Comment created by @ocramius:

[~dotlabel-scott] thanks - changed resolution

@doctrinebot

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)

@Ocramius Ocramius was assigned by doctrinebot Dec 6, 2015
@doctrinebot doctrinebot closed this Dec 6, 2015
@doctrinebot doctrinebot added the Bug label Dec 7, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment