{"action":"created","issue":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1064","labels_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1064/labels{/name}","comments_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1064/comments","events_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1064/events","html_url":"https://github.com/doctrine/mongodb-odm/issues/1064","id":64935371,"number":1064,"title":"Document updates not working when extending another document","user":{"login":"lenardpalko","id":1013821,"avatar_url":"https://avatars.githubusercontent.com/u/1013821?v=3","gravatar_id":"","url":"https://api.github.com/users/lenardpalko","html_url":"https://github.com/lenardpalko","followers_url":"https://api.github.com/users/lenardpalko/followers","following_url":"https://api.github.com/users/lenardpalko/following{/other_user}","gists_url":"https://api.github.com/users/lenardpalko/gists{/gist_id}","starred_url":"https://api.github.com/users/lenardpalko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lenardpalko/subscriptions","organizations_url":"https://api.github.com/users/lenardpalko/orgs","repos_url":"https://api.github.com/users/lenardpalko/repos","events_url":"https://api.github.com/users/lenardpalko/events{/privacy}","received_events_url":"https://api.github.com/users/lenardpalko/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-28T12:03:07Z","updated_at":"2015-11-03T21:25:21Z","closed_at":"2015-11-03T21:25:21Z","body":"I have the following setup : \r\nA document `BoosterTerm` extending document `Term`, and every `BoosterTerm` can have a `BoosterTerm` as a parent.\r\n\r\nNow the issue is when I get $boosterTerm->getParent() and update a value on it and then flush the value is not saved in the DB, there is no exception, no error, the values are simply not saved in the DB.\r\n\r\nHere are some code examples : \r\n```yaml\r\nAcme\\Bundle\\Document\\Term:\r\n    repositoryClass: Acme\\Bundle\\Repository\\TermRepository\r\n    collection: terms\r\n    type: document\r\n    inheritanceType: COLLECTION_PER_CLASS\r\n    fields:\r\n        id:\r\n            id: true\r\n        name:\r\n            type: string\r\n        parent:\r\n            reference: true\r\n            type: one\r\n            nullable: true\r\n            targetDocument: Acme\\Bundle\\Document\\Term\r\n```\r\n```yaml\r\nAcme\\Bundle\\Document\\BoosterTerm:\r\n    repositoryClass: Acme\\Bundle\\Repository\\BoosterTermRepository\r\n    collection: booster_terms\r\n    type: document\r\n    fields:\r\n        id:\r\n            id: true\r\n        creation:\r\n            type: boolean\r\n        parent:\r\n            reference: true\r\n            type: one\r\n            targetDocument: Acme\\Bundle\\Document\\BoosterTerm\r\n            inversedBy: children\r\n        children:\r\n            reference: true\r\n            type: many\r\n            targetDocument: Acme\\Bundle\\Document\\BoosterTerm\r\n            mappedBy: parent\r\n```\r\n\r\n```php\r\n<?php\r\nclass BoosterTerm extends Term\r\n```\r\n\r\nAfter digging a while I think I found what the issue is, but not sure where the source of the issue is.\r\nIn `Doctrine/ODM/MongoDB/UnitOfWork.php` in function `executeUpdates` on line `1186` in the master-dev version.\r\n\r\n```php\r\nif (get_class($document) == $className || $document instanceof Proxy && $document instanceof $className) {\r\n```\r\nevaluates as true for a `BoosterTerm` document when `$className` is actually `Acme\\Bundle\\Document\\Term` and it continues until `Doctrine/MongoDB/Collection.php` line `1243` :\r\n```php\r\nreturn $this->mongoCollection->update($query, $newObj, $options);\r\n```\r\n\r\nbut after that line is executed nothing happens in the DB.\r\n\r\nI've made it work only after I removed the `Acme\\Bundle\\Document\\Term` from the `$commitOrder` array in `UnitOfWork`.\r\n\r\nSo there migth be three sources of the issue :\r\n1. `Acme\\Bundle\\Document\\Term` should not appear in `$commitOrder` as no Document with this type has been modified.\r\n2. the order in the `$commitOrder` is not ok as `Acme\\Bundle\\Document\\Term` appears before `Acme\\Bundle\\Document\\BoosterTerm`\r\n3. line `1186` in UnitOfWork should match only the instance of the child class and not the parent class also.\r\n\r\nI hope this really is an issue and you can understand what is happening.\r\n\r\nI would like to work on this issue if somebody would guide me a little between the 3 above solutions."},"comment":{"url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/comments/153494067","html_url":"https://github.com/doctrine/mongodb-odm/issues/1064#issuecomment-153494067","issue_url":"https://api.github.com/repos/doctrine/mongodb-odm/issues/1064","id":153494067,"user":{"login":"malarzm","id":4947711,"avatar_url":"https://avatars.githubusercontent.com/u/4947711?v=3","gravatar_id":"","url":"https://api.github.com/users/malarzm","html_url":"https://github.com/malarzm","followers_url":"https://api.github.com/users/malarzm/followers","following_url":"https://api.github.com/users/malarzm/following{/other_user}","gists_url":"https://api.github.com/users/malarzm/gists{/gist_id}","starred_url":"https://api.github.com/users/malarzm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/malarzm/subscriptions","organizations_url":"https://api.github.com/users/malarzm/orgs","repos_url":"https://api.github.com/users/malarzm/repos","events_url":"https://api.github.com/users/malarzm/events{/privacy}","received_events_url":"https://api.github.com/users/malarzm/received_events","type":"User","site_admin":false},"created_at":"2015-11-03T21:25:21Z","updated_at":"2015-11-03T21:25:21Z","body":"`CommitOrder` is removed for some time now, but if the issue still exists please feel free to submit a failing test case"}}