-
-
Notifications
You must be signed in to change notification settings - Fork 224
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
AbstractExecutor clearing ObjectManager after every load() #162
Comments
why shouldn't it be cleared ? The ReferenceRepository already takes care of giving you a managed instance when getting the reference back |
it should not be cleared because of this public function getReference($name)
{
$reference = $this->references[$name];
$meta = $this->manager->getClassMetadata(get_class($reference));
$uow = $this->manager->getUnitOfWork();
if (!$uow->isInIdentityMap($reference) && isset($this->identities[$name])) {
$reference = $this->manager->getReference(
$meta->name,
$this->identities[$name]
);
$this->references[$name] = $reference; // already in identity map
}
return $reference;
} the manager being used by reference repository and the one used by loader is the same, so it is influencing directly and causing ORM to load entity every time |
@tiger-seo if the UoW is not cleared, Computing the changeset in each fixture files requires checking all previously loaded entities for changes. This is why clearing the EntityManager has been added. and note that |
but it does loading, at least for associations |
depends what you are doing with your associations |
if your entity has composite identity from association than you will not be able to persist them with out intermediate flush |
https://github.com/doctrine/data-fixtures/blob/master/lib/Doctrine/Common/DataFixtures/Executor/AbstractExecutor.php#L122
In a project of mine I have a case of two dependent fixtures in which the ObjectManager should not have been cleared between their load(). I think it would be better if we don't call $manager->clear() if we are in case of dependent fixtures (or at least have an option to avoid that), what do you think @Ocramius ?
The text was updated successfully, but these errors were encountered: