{"action":"closed","issue":{"url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/547","repository_url":"https://api.github.com/repos/doctrine/DoctrineBundle","labels_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/547/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/547/comments","events_url":"https://api.github.com/repos/doctrine/DoctrineBundle/issues/547/events","html_url":"https://github.com/doctrine/DoctrineBundle/issues/547","id":158347196,"number":547,"title":"UnitOfWork->clear doesn't clear entityInsertions when entityName is passed","user":{"login":"ricohumme","id":11029998,"avatar_url":"https://avatars.githubusercontent.com/u/11029998?v=3","gravatar_id":"","url":"https://api.github.com/users/ricohumme","html_url":"https://github.com/ricohumme","followers_url":"https://api.github.com/users/ricohumme/followers","following_url":"https://api.github.com/users/ricohumme/following{/other_user}","gists_url":"https://api.github.com/users/ricohumme/gists{/gist_id}","starred_url":"https://api.github.com/users/ricohumme/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ricohumme/subscriptions","organizations_url":"https://api.github.com/users/ricohumme/orgs","repos_url":"https://api.github.com/users/ricohumme/repos","events_url":"https://api.github.com/users/ricohumme/events{/privacy}","received_events_url":"https://api.github.com/users/ricohumme/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-06-03T11:29:54Z","updated_at":"2016-06-03T11:53:03Z","closed_at":"2016-06-03T11:53:03Z","body":"Hi,\r\n\r\nI found that when I was clearing the EntityManager for a specific entity class, only detach is executed for entities within the identityMap.\r\nClearing the scheduled insertions for that class isn't done. \r\nDid anyone else experience this?\r\nWhat I found is that newly persisted entities are not added to the identityMap and therefor are not removed.\r\n\r\nMy solution to this issue would be the following:\r\n```php\r\n// Class UnitOfWork\r\n// Method clear\r\nif ($entityName === null) {\r\n    ...\r\n} else {\r\n\tforeach ($this->identityMap as $className => $entities) {\r\n\t\t...\r\n\t}\r\n\r\n\tforeach ($this->entityInsertions as $hash => $entity) {\r\n\t\tif (get_class($entity) != $entityName) {\r\n\t\t\tcontinue;\r\n\t\t}\r\n\t\tunset($this->entityInsertions[$hash]);\r\n\t}\r\n}\r\n```\r\nThis has been proven to work in my case.\r\n\r\nLet me know what you think"}}
{"actor":{"display_login":"ricohumme"}}