DDC-1585: Doctrine2 doesn't check for the correct entity type on @ManyToOne relations #1986

Closed
opened 2026-01-22 13:36:16 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Jan 7, 2012).

Originally assigned to: @beberlei on GitHub.

Jira issue originally created by user felicitus:

I made a mistake when creating a @ManyToOne entity:

/****

  • @ManyToOne(targetEntity="Entities\EntityA")
    */
    private $test;

However, I was setting Entities\EntityB into $test.

Doctrine2 doesn't check for this, resulting in a hard-to-find issue.

Originally created by @doctrinebot on GitHub (Jan 7, 2012). Originally assigned to: @beberlei on GitHub. Jira issue originally created by user felicitus: I made a mistake when creating a @ManyToOne entity: /**** - @ManyToOne(targetEntity="Entities\EntityA") */ private $test; However, I was setting Entities\EntityB into $test. Doctrine2 doesn't check for this, resulting in a hard-to-find issue.
admin added the Bug label 2026-01-22 13:36:16 +01:00
admin closed this issue 2026-01-22 13:36:23 +01:00
Author
Owner

@doctrinebot commented on GitHub (Jan 7, 2012):

@doctrinebot commented on GitHub (Jan 7, 2012): - duplicates [DBAL-479: Doctrine2 schema-tool:update doesn't re-create foreign keys on entity change](http://www.doctrine-project.org/jira/browse/DBAL-479)
Author
Owner

@doctrinebot commented on GitHub (Jan 13, 2012):

Comment created by @guilhermeblanco:

Duplicated

@doctrinebot commented on GitHub (Jan 13, 2012): Comment created by @guilhermeblanco: Duplicated
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2012):

Comment created by @beberlei:

This is not a duplicate, its a runtime issue in the code when setting the wrong target entity type.

@doctrinebot commented on GitHub (Jan 15, 2012): Comment created by @beberlei: This is not a duplicate, its a runtime issue in the code when setting the wrong target entity type.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2012):

Comment created by @beberlei:

Implemented an instanceof check.

@doctrinebot commented on GitHub (Jan 15, 2012): Comment created by @beberlei: Implemented an instanceof check.
Author
Owner

@doctrinebot commented on GitHub (Jan 15, 2012):

Issue was closed with resolution "Fixed"

@doctrinebot commented on GitHub (Jan 15, 2012): 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#1986