Doctrine 1
  1. Doctrine 1
  2. DC-871

When importing fixtures some times the fixtures will be loaded in the wrong order causing broken foreign key relations

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: None
    • Component/s: Import/Export
    • Labels:
      None
    • Environment:
      XP Xamp

      Description

      Hi

      I recently encountered a problem when importing fixtures. I was ending up with invalid foreign key constraints due to the fact that the fixtures were importing in the wrong order. I tracked down the problem and figured out that the method Doctrine_Connection_UnitOfWork::buildFlushTree, while a truly impressive piece of sorting logic still some times still gets the order of the classes wrong in its end result.

      I realized that all it needed though was a second shot at reordering the list – in other words it needed to exhaustively try to order the list until it found that everything was in the right order.

      I put in a for loop in this method that will keep running until no order changes occurred or until a max number of attempts have been reached. The max number of attempts I added as a property of Doctrine_Connection called: maxBuildFlushTreeOrderAttempts.

      This has solved my problem. I wouldn't be surprised if this was a common issue.

      I will post my patch into this thread.

      Hope all is well.

      Will Ferrer

        Activity

        Hide
        will ferrer added a comment -

        Here is the patch

        Show
        will ferrer added a comment - Here is the patch

          People

          • Assignee:
            Jonathan H. Wage
            Reporter:
            will ferrer
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: