Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1585

Doctrine2 doesn't check for the correct entity type on @ManyToOne relations

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.5
    • Fix Version/s: 2.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      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.

        Issue Links

          Activity

          Hide
          Benjamin Eberlei added a comment -

          Implemented an instanceof check.

          Show
          Benjamin Eberlei added a comment - Implemented an instanceof check.
          Hide
          Benjamin Eberlei added a comment -

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

          Show
          Benjamin Eberlei added a comment - This is not a duplicate, its a runtime issue in the code when setting the wrong target entity type.
          Hide
          Guilherme Blanco added a comment -

          Duplicated

          Show
          Guilherme Blanco added a comment - Duplicated

            People

            • Assignee:
              Benjamin Eberlei
              Reporter:
              Timo A. Hummel
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: