Bug #40389

Orphan Removal in ManyToMany Associations

Added by Christian Müller about 9 years ago. Updated about 9 years ago.

Status:
Resolved
Priority:
Must have
Category:
Persistence
Start date:
2012-08-29
Due date:
% Done:

100%

Estimated time:
PHP Version:
Has patch:
No
Complexity:
easy

Description

The orphanRemoval option in a ManyToMany annotation defaults to FALSE.

In the Flow3AnnotationDriver a check is made for $manyToManyAnnotation->orphanRemoval which in turn will always be FALSE because it is the default (and not only when it was actually set to FALSE in the annotation, which seems to have been the intention of the check). Therefor unless you set it to TRUE anyway it will always go to the elseif which checks if the associated entity has a repository and then sets orphanRemoval to TRUE.

Which means that if you have a ManyToMany relation where one entity has no Repository that will end up with orphanRemoval TRUE regardless of what you really annotated. This is not really the expected behaviour and especially for ManyToMany often wrong too.

I suggest to remove the check for ManyToMany relations and use the actual value that is annotated (or the default FALSE), but that of course is a breaking change as it will leave orphans behind in cases people unknowingly accepted this (wrong) behaviour.


Related issues

Related to Doctrine.ORM - Bug #33921: Doctrine's removeElement() deletes OneToMany objects without repository updateClosedKarsten Dambekalns2012-02-14

Actions
#1

Updated by Gerrit Code Review about 9 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14211

#2

Updated by Gerrit Code Review about 9 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14211

#3

Updated by Karsten Dambekalns about 9 years ago

  • Assignee set to Christian Müller
  • Target version set to 2.0 beta 1
#4

Updated by Gerrit Code Review about 9 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/14211

#5

Updated by Christian Müller about 9 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

Also available in: Atom PDF