Doctrine 2 - ORM
  1. Doctrine 2 - ORM
  2. DDC-1113

getCommitOrder misses some relations when used with Inheritance and self-referencing field

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Critical Critical
    • Resolution: Fixed
    • Affects Version/s: Git Master
    • Fix Version/s: 2.1.2
    • Component/s: ORM
    • Security Level: All
    • Labels:
      None

      Description

      Let's assume we have an Entity class "ParentClass", which uses a single table inheritance with child classes "ChildOne" and "ChildTwo".
      "ParentClass" also have one-to-one unidirectional association with "FooBar" class named "foobar", and a self-referencing association called "parent"

      We construct entity of "ChildOne" type, filling "foobar" link with new FooBar object. The same action is made for entity of "ChildTwo" type.
      Entity of "ChildOne" type is persisted and flushed.

      At this point getCommitOrder builds a commit order. ChildOne <---> FooBar link appears in dependency graph because of "foobar" association.
      While processing assocs it reveals "parent" assoc in parent class and builds following links in dependency graph:
      ChildOne <---> ChildOne
      ChildOne <---> ChildTwo

      After that "ChildTwo" entity is persisted and flushed. At this point commit calculator thinks it already have "ChildTwo" in it's storage so no assoc calculation are made for "childTwo" class

      If we attemp to delete "ChildTwo" class flush() will fail because of missing link "ChildTwo <-----> Foobar" assoc

        Activity

        Hide
        Illya Klymov added a comment -

        I've opened pull request https://github.com/doctrine/doctrine2/pull/47 with my fix to this issue. I'm new to doctrine development so feel free to make any suggestions how to improve it

        Show
        Illya Klymov added a comment - I've opened pull request https://github.com/doctrine/doctrine2/pull/47 with my fix to this issue. I'm new to doctrine development so feel free to make any suggestions how to improve it
        Hide
        Benjamin Eberlei added a comment -

        Increased priority, i should really look at this one soon!

        Show
        Benjamin Eberlei added a comment - Increased priority, i should really look at this one soon!
        Hide
        Benjamin Eberlei added a comment -

        The test with this pull request does not fail even without the applied patch.

        Show
        Benjamin Eberlei added a comment - The test with this pull request does not fail even without the applied patch.
        Hide
        Benjamin Eberlei added a comment -

        sorry my bad, ran this with SQLite (Which has no FKs)

        Show
        Benjamin Eberlei added a comment - sorry my bad, ran this with SQLite (Which has no FKs)
        Hide
        Benjamin Eberlei added a comment -

        Fixed, simplifed a bit since one part was not necessary and this hits performance quite significantly

        Show
        Benjamin Eberlei added a comment - Fixed, simplifed a bit since one part was not necessary and this hits performance quite significantly

          People

          • Assignee:
            Benjamin Eberlei
            Reporter:
            Illya Klymov
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: