8000 UnitOfWork->clear doesn't clear entityInsertions when entityName is passed · Issue #5849 · doctrine/orm · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
UnitOfWork->clear doesn't clear entityInsertions when entityName is passed #5849
Closed
@ricohumme

Description

@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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0