Referencing same object multiple times before flushing #57

Closed
deeky666 opened this Issue Aug 14, 2012 · 1 comment

Comments

Projects
None yet
3 participants
Member

deeky666 commented Aug 14, 2012

I just encountered a problem with referencing an object multiple times with different names before flushing. It seems only the first reference I make gets persisted and is available in following fixtures. Here is an example:

public function load(ObjectManager $manager)
{
        $obj = new Obj();
        $obj->setFoo('bar');

        $manager->persist($obj);

        $this->addReference('first-reference', $obj);
        $this->addReference('second-reference', $obj);

        $manager->flush();
}

When referencing "first-reference" in the following fixture I get the persisted object I expect. But if I reference "second-reference" I get an object that is in an unpersisted state. This is problematic if I want to relate the previously persisted object to another object in a following fixture by referencing "second-reference".
If I flush before adding the references, everything works fine. Is it a bug or an intended behaviour?

Member

stof commented Aug 20, 2012

Please report it to the DataFixtures library. This bundle only provides the command calling the library, not the fixture loading logic.

lavoiesl closed this Mar 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment