DDC-2775: Bug with cascade remove #3470

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

Originally created by @doctrinebot on GitHub (Nov 4, 2013).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user mnapoli:

I have met a bug with cascade remove that I managed to reproduce with this use case (see also the diagram in the attachments):

  • User has many Roles
  • Roles has many Authorization
  • User has also many Authorization (cache of all authorizations of all roles)

All these associations are bidirectional, and with "cascade remove".

When I remove User:

User cascade remove on Role

Role cascade remove on Authorization

User cascade remove on Authorization

If collections are lazy-loaded, then step 1. will clear the roles from the identityMap, but step 3. will reload the roles (because the authorizations will be lazy-loaded) and re-insert them in the identityMap.

As a consequence, the first flush() succeeds, but any further flush() yields:

[Doctrine\ORM\ORMInvalidArgumentException] A new entity was found through the relationship 'Role#user' that was not configured to cascade persist operations for entity...

I am creating a PR with a testcase, and probably a fix.

Originally created by @doctrinebot on GitHub (Nov 4, 2013). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user mnapoli: I have met a bug with cascade remove that I managed to reproduce with this use case (see also the diagram in the attachments): - User has many Roles - Roles has many Authorization - User has also many Authorization (cache of all authorizations of all roles) All these associations are bidirectional, and with "cascade remove". When I remove User: # User cascade remove on Role # Role cascade remove on Authorization # User cascade remove on Authorization **If collections are lazy-loaded**, then step 1. will clear the roles from the identityMap, but step 3. will reload the roles (because the authorizations will be lazy-loaded) and re-insert them in the identityMap. As a consequence, the first flush() succeeds, but any further flush() yields: `[Doctrine\ORM\ORMInvalidArgumentException] A new entity was found through the relationship 'Role#user' that was not configured to cascade persist operations for entity...` I am creating a PR with a testcase, and probably a fix.
admin added the Bug label 2026-01-22 14:20:29 +01:00
admin closed this issue 2026-01-22 14:20:29 +01:00
Author
Owner

@doctrinebot commented on GitHub (Nov 4, 2013):

Comment created by mnapoli:

PR : https://github.com/doctrine/doctrine2/pull/837

@doctrinebot commented on GitHub (Nov 4, 2013): Comment created by mnapoli: PR : https://github.com/doctrine/doctrine2/pull/837
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-837] was closed:
https://github.com/doctrine/doctrine2/pull/837

@doctrinebot commented on GitHub (Jan 2, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-837] was closed: https://github.com/doctrine/doctrine2/pull/837
Author
Owner

@doctrinebot commented on GitHub (Jan 2, 2014):

Issue was closed with resolution "Fixed"

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

No dependencies set.

Reference: doctrine/archived-orm#3470