Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(persister): added condition to check if entity values are array #203

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

santoslluis
Copy link

I had the same issue here: #202
It was working well until I update the library.

Error context:

TypeError : Argument 2 passed to Fidry\AliceDataFixtures\Bridge\Doctrine\Persister\ObjectManagerPersister::getMetadata() must be an object, array given

I defined the relationship datatype as array and not as Collection or ArrayCollection.

    /**
     * @var Instance[]
     * @ORM\OneToMany(targetEntity=Instance::class, mappedBy="strategy")
     */
    public $instances = [];

It seems that if you didn't specify the datatype as Collection or ArrayCollection, the library loads it as array, and after in inner checks It only checks if it's a Collection, otherwise threats it as a Object, so it throws a TypeError.

What I did

I added a check if it is an array, and processed it like if it was a Collection.

For me it is working, hope it helps.

@theofidry
Copy link
Owner

Thanks for the PR! Would it be possible to have an anti-regression test as well? It is a sensitive part which has broke quite a few times already... I think you should find a couple of examples in the test suite already and running the tests should only be a matter of doing make test (hopefully). If you need more help there don't hesitate to ping me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants