doctrine / data-fixtures

Doctrine2 ORM Data Fixtures Extensions
http://www.doctrine-project.org
MIT License
2.78k stars 224 forks source link

TopologicalSorter breaks fixture load #228

Closed peterrehm closed 8 years ago

peterrehm commented 8 years ago

The TopologicalSorter throws the error:

 Graph contains cyclic dependency. An example of this problem would be the following: Class C has class B as its dependency. Then, class B has class A has its dependency. Finally, class A has class C as its dependency. 

Everything was working before. As the error is not providing much information I will investigate further.

peterrehm commented 8 years ago

It looks like this might be due to a self referencing entity.

magnetik commented 8 years ago

Indeed it happens for me on a self referencing ManyToOne in my case.

peterrehm commented 8 years ago

Just provided a PR, let's see if this is the solution already.

AxaliaN commented 8 years ago

I hope it gets merged soon, same issue on our end.

Xen3r0 commented 8 years ago

I have the same problem, can't start my fixtures :(

Anyone have a solution ?

AxaliaN commented 8 years ago

@Xen3r0 Use version 1.1.1 for now, it's what I did.

kniziol commented 8 years ago

Same problem here. Cannot load DataFixtures with entities that reference them self. Removing those entities solves the problem, but it's not a good solution, because many data is not loaded while recreating database... I have a Category entity who implements tree functionality based on @Gedmo\TreeParent. So, the Category contains reference to itself and... that's the problem.

Using version 1.1.1 solves the problem too, but it's temporarily solution.

cfuerst commented 8 years ago

Same issue here with Gedmo\Tree 👍

peterrehm commented 8 years ago

Can you try if my fix resolves it for your use cases?

Ocramius commented 8 years ago

Please, folks, come up with test cases and sample scenarios that we can put in the test suite. We know that the new TopologicalSorter is not 100% reflecting what was in ORM 2.5, but we can't do much about it without actual tests that cover the solved problems.

geoffrey-brier commented 8 years ago

@Ocramius In my case the fixtures load correctly but if I reload them, the DELETE FROM <table> statements break everything (after upgrading from 1.1 to 1.2). I could provide the schema and alice fixtures but it's quite big.

peterrehm commented 8 years ago

@geoffrey-brier Your issue might not be solved with the merged PR. Please check this again and open an issue if it still exists.