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

UnitOfWork->clear doesn't clear entityInsertions when entityName is passed #5849

Closed
ricohumme opened this Issue Jun 3, 2016 · 1 comment

Comments

Projects
None yet
2 participants
@ricohumme

Hi,

I found that when I was clearing the EntityManager for a specific entity class, only detach is executed for entities within the identityMap.
Clearing the scheduled insertions for that class isn't done.
Did anyone else experience this?
What I found is that newly persisted entities are not added to the identityMap and therefor are not removed.

My solution to this issue would be the following:

// Class UnitOfWork
// Method clear
if ($entityName === null) {
    ...
} else {
    foreach ($this->identityMap as $className => $entities) {
        ...
    }

    foreach ($this->entityInsertions as $hash => $entity) {
        if (get_class($entity) != $entityName) {
            continue;
        }
        unset($this->entityInsertions[$hash]);
    }
}

This has been proven to work in my case.

Let me know what you think

For this I created a pull request

@Ocramius Ocramius added the Bug label Jun 5, 2016

@Ocramius Ocramius added this to the 2.5.5 milestone Jun 5, 2016

@Ocramius Ocramius self-assigned this Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

@Ocramius Ocramius closed this in 3bc61d5 Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

#5849 #5850 correcting test scenario: identity map could not be buil…
…t with auto-generated identities+persist

Ocramius added a commit that referenced this issue Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

Ocramius added a commit that referenced this issue Jun 5, 2016

Merge branch 'fix/#5850-clearing-specific-entity-name-should-clear-al…
…so-its-entity-insertions-2.5' into 2.5

Close #5850
Close #5849
@Ocramius

This comment has been minimized.

Show comment
Hide comment
@Ocramius

Ocramius Jun 5, 2016

Member

Handled in #5850

Member

Ocramius commented Jun 5, 2016

Handled in #5850

alexgurrola added a commit to Sitetheory-Archive/doctrine2 that referenced this issue Apr 13, 2017

alexgurrola added a commit to Sitetheory-Archive/doctrine2 that referenced this issue Apr 13, 2017

alexgurrola added a commit to Sitetheory-Archive/doctrine2 that referenced this issue Apr 13, 2017

alexgurrola added a commit to Sitetheory-Archive/doctrine2 that referenced this issue Apr 13, 2017

alexgurrola added a commit to Sitetheory-Archive/doctrine2 that referenced this issue Apr 13, 2017

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