{"action":"created","issue":{"url":"https://api.github.com/repos/orocrm/platform/issues/624","repository_url":"https://api.github.com/repos/orocrm/platform","labels_url":"https://api.github.com/repos/orocrm/platform/issues/624/labels{/name}","comments_url":"https://api.github.com/repos/orocrm/platform/issues/624/comments","events_url":"https://api.github.com/repos/orocrm/platform/issues/624/events","html_url":"https://github.com/orocrm/platform/issues/624","id":203069490,"number":624,"title":"'annon.' user cause exception in event listener","user":{"login":"sadortun","id":794449,"avatar_url":"https://avatars.githubusercontent.com/u/794449?v=3","gravatar_id":"","url":"https://api.github.com/users/sadortun","html_url":"https://github.com/sadortun","followers_url":"https://api.github.com/users/sadortun/followers","following_url":"https://api.github.com/users/sadortun/following{/other_user}","gists_url":"https://api.github.com/users/sadortun/gists{/gist_id}","starred_url":"https://api.github.com/users/sadortun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sadortun/subscriptions","organizations_url":"https://api.github.com/users/sadortun/orgs","repos_url":"https://api.github.com/users/sadortun/repos","events_url":"https://api.github.com/users/sadortun/events{/privacy}","received_events_url":"https://api.github.com/users/sadortun/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-25T10:50:04Z","updated_at":"2017-02-01T15:34:03Z","closed_at":null,"body":"Hi, when  the securityToken contain an annonymous user, and a persist is done, the following exception is thrown:\r\n>>>\r\nFatal error: Uncaught Error: Call to a member function getOwner() on string in /var/www/orocrm/vendor/oro/platform/src/Oro/Bundle/OrganizationBundle/EventListener/RecordOwnerDataListener.php:114 Stack trace: #0 \r\n>>>\r\n\r\nI am not sure what is the extent of usage of this method, but here is a suggestion: \r\n\r\nhttps://github.com/orocrm/platform/blob/master/src/Oro/Bundle/OrganizationBundle/EventListener/RecordOwnerDataListener.php#L114\r\n```php\r\n// original code\r\n// $user may === 'annon.'\r\n            $owner = null;\r\n            if ($user instanceof User) {\r\n                $owner = $user;\r\n            } elseif ($user->getOwner() instanceof User) {\r\n                $owner = $user->getOwner();\r\n            }\r\n```\r\n```php\r\n// suggested update \r\n            if ($user instanceof User) {\r\n                $owner = $user;\r\n            } elseif (is_object($user) && method_exists($user, 'getOwner') && $user->getOwner() instanceof User) {\r\n                $owner = $user->getOwner();\r\n            }\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/orocrm/platform/issues/comments/276688954","html_url":"https://github.com/orocrm/platform/issues/624#issuecomment-276688954","issue_url":"https://api.github.com/repos/orocrm/platform/issues/624","id":276688954,"user":{"login":"mkudelya","id":3332593,"avatar_url":"https://avatars.githubusercontent.com/u/3332593?v=3","gravatar_id":"","url":"https://api.github.com/users/mkudelya","html_url":"https://github.com/mkudelya","followers_url":"https://api.github.com/users/mkudelya/followers","following_url":"https://api.github.com/users/mkudelya/following{/other_user}","gists_url":"https://api.github.com/users/mkudelya/gists{/gist_id}","starred_url":"https://api.github.com/users/mkudelya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkudelya/subscriptions","organizations_url":"https://api.github.com/users/mkudelya/orgs","repos_url":"https://api.github.com/users/mkudelya/repos","events_url":"https://api.github.com/users/mkudelya/events{/privacy}","received_events_url":"https://api.github.com/users/mkudelya/received_events","type":"User","site_admin":false},"created_at":"2017-02-01T15:34:03Z","updated_at":"2017-02-01T15:34:03Z","body":"Hi @sadortun \r\n\r\nHow i can reproduce the issue ?"}}
{"actor":{"display_login":"mkudelya"}}