{"action":"created","issue":{"url":"https://api.github.com/repos/modxcms/xpdo/issues/72","labels_url":"https://api.github.com/repos/modxcms/xpdo/issues/72/labels{/name}","comments_url":"https://api.github.com/repos/modxcms/xpdo/issues/72/comments","events_url":"https://api.github.com/repos/modxcms/xpdo/issues/72/events","html_url":"https://github.com/modxcms/xpdo/issues/72","id":103995661,"number":72,"title":"$xpdoObject->remove() & relationships","user":{"login":"rtripault","id":300920,"avatar_url":"https://avatars.githubusercontent.com/u/300920?v=3","gravatar_id":"","url":"https://api.github.com/users/rtripault","html_url":"https://github.com/rtripault","followers_url":"https://api.github.com/users/rtripault/followers","following_url":"https://api.github.com/users/rtripault/following{/other_user}","gists_url":"https://api.github.com/users/rtripault/gists{/gist_id}","starred_url":"https://api.github.com/users/rtripault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtripault/subscriptions","organizations_url":"https://api.github.com/users/rtripault/orgs","repos_url":"https://api.github.com/users/rtripault/repos","events_url":"https://api.github.com/users/rtripault/events{/privacy}","received_events_url":"https://api.github.com/users/rtripault/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-31T06:25:25Z","updated_at":"2015-08-31T11:09:48Z","closed_at":null,"body":"### Summary\r\n\r\nFirst of all, i'm not sure if this is a bug (for my specific case) or rather the expected behavior.\r\nAfter moving all relationships from one object to another, removing the object where all relationships were initially \"attached to\", the relationships are also deleted (i believe because of some kind of caching).\r\n\r\n### Step to reproduce\r\n\r\n```php\r\n<?php\r\n$object1 = $xpdo->getObject('class', 'pk1');\r\n$object2 = $xpdo->getObject('class', 'pk2');\r\n\r\nforeach ($object1->getMany('relationships') as $r) {\r\n    $r->set('relationship_object_id', $object2->get('id');\r\n    $r->save();\r\n}\r\n\r\n$object1->remove();\r\n```\r\n\r\n### Observed behavior\r\n\r\nAll related objects are also deleted whith `$object1->remove()`\r\n`$object2->getMany('relatioships)` is empty\r\n\r\n### Expected behavior\r\n\r\nRelated objects should be attached to `$object2`.\r\nI believe this is because `getMany` uses some caching mechanism. If so, `$xpdoObject->remove()` should not make use of the caching (or provide some argument to \"bypass\" the caching mechanism).\r\n"},"comment":{"url":"https://api.github.com/repos/modxcms/xpdo/issues/comments/136336588","html_url":"https://github.com/modxcms/xpdo/issues/72#issuecomment-136336588","issue_url":"https://api.github.com/repos/modxcms/xpdo/issues/72","id":136336588,"user":{"login":"rtripault","id":300920,"avatar_url":"https://avatars.githubusercontent.com/u/300920?v=3","gravatar_id":"","url":"https://api.github.com/users/rtripault","html_url":"https://github.com/rtripault","followers_url":"https://api.github.com/users/rtripault/followers","following_url":"https://api.github.com/users/rtripault/following{/other_user}","gists_url":"https://api.github.com/users/rtripault/gists{/gist_id}","starred_url":"https://api.github.com/users/rtripault/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rtripault/subscriptions","organizations_url":"https://api.github.com/users/rtripault/orgs","repos_url":"https://api.github.com/users/rtripault/repos","events_url":"https://api.github.com/users/rtripault/events{/privacy}","received_events_url":"https://api.github.com/users/rtripault/received_events","type":"User","site_admin":false},"created_at":"2015-08-31T11:09:48Z","updated_at":"2015-08-31T11:09:48Z","body":"Well, that's somehow what i meant, if the code, i would have expected `$r->set('relationship_object_id', $object2->get('id');` to \"kill\" that relationship from parent object1 to object2"}}