Uploaded image for project: '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


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



      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


        willf1976 will ferrer added a comment -

        Here is the patch

        willf1976 will ferrer added a comment - Here is the patch


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


            • Created: