{"action":"created","issue":{"url":"https://api.github.com/repos/amitaibu/og/issues/216","repository_url":"https://api.github.com/repos/amitaibu/og","labels_url":"https://api.github.com/repos/amitaibu/og/issues/216/labels{/name}","comments_url":"https://api.github.com/repos/amitaibu/og/issues/216/comments","events_url":"https://api.github.com/repos/amitaibu/og/issues/216/events","html_url":"https://github.com/amitaibu/og/issues/216","id":157176743,"number":216,"title":"Trouble exporting roles in config due to magic ID prefixing","user":{"login":"pfrenssen","id":442924,"avatar_url":"https://avatars.githubusercontent.com/u/442924?v=3","gravatar_id":"","url":"https://api.github.com/users/pfrenssen","html_url":"https://github.com/pfrenssen","followers_url":"https://api.github.com/users/pfrenssen/followers","following_url":"https://api.github.com/users/pfrenssen/following{/other_user}","gists_url":"https://api.github.com/users/pfrenssen/gists{/gist_id}","starred_url":"https://api.github.com/users/pfrenssen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pfrenssen/subscriptions","organizations_url":"https://api.github.com/users/pfrenssen/orgs","repos_url":"https://api.github.com/users/pfrenssen/repos","events_url":"https://api.github.com/users/pfrenssen/events{/privacy}","received_events_url":"https://api.github.com/users/pfrenssen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-05-27T10:28:18Z","updated_at":"2016-05-31T06:28:07Z","closed_at":null,"body":"Currently when a new `OgRole` is saved, the role ID gets prefixed with the group entity type ID and the group bundle ID in `OgRole::save()`:\r\n\r\n```\r\n  public function save() {\r\n    if ($this->isNew()) {\r\n      // When assigning a role to group we need to add a prefix to the ID in\r\n      // order to prevent duplicate IDs.\r\n      $prefix = $this->getGroupType() . '-' . $this->getGroupBundle() . '-';\r\n\r\n      if (!empty($this->getGroupId())) {\r\n        $prefix .= $this->getGroupId() . '-';\r\n      }\r\n\r\n      $this->id = $prefix . $this->id();\r\n    }\r\n\r\n    parent::save();\r\n  }\r\n```\r\n\r\nThis however causes problems in install profiles and modules supplying roles in config. Whenever a profile or module is installed, a new OgRole is saved with the ID that is read from the YAML file which will already contain the prefix, causing it to be prefixed twice. This can be worked around by manually editing the YAML file, but then the problem will reappear on a subsequent config exports.\r\n\r\nThis will probably also happen when moving config from staging to production, since the same cycle will occur.\r\n\r\nWe probably should not do any magic prefixing. It would be better to require the correct ID to be set and check this in OgRole::save()."},"comment":{"url":"https://api.github.com/repos/amitaibu/og/issues/comments/222602695","html_url":"https://github.com/amitaibu/og/issues/216#issuecomment-222602695","issue_url":"https://api.github.com/repos/amitaibu/og/issues/216","id":222602695,"user":{"login":"amitaibu","id":125707,"avatar_url":"https://avatars.githubusercontent.com/u/125707?v=3","gravatar_id":"","url":"https://api.github.com/users/amitaibu","html_url":"https://github.com/amitaibu","followers_url":"https://api.github.com/users/amitaibu/followers","following_url":"https://api.github.com/users/amitaibu/following{/other_user}","gists_url":"https://api.github.com/users/amitaibu/gists{/gist_id}","starred_url":"https://api.github.com/users/amitaibu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amitaibu/subscriptions","organizations_url":"https://api.github.com/users/amitaibu/orgs","repos_url":"https://api.github.com/users/amitaibu/repos","events_url":"https://api.github.com/users/amitaibu/events{/privacy}","received_events_url":"https://api.github.com/users/amitaibu/received_events","type":"User","site_admin":false},"created_at":"2016-05-31T06:28:07Z","updated_at":"2016-05-31T06:28:07Z","body":"👍 "}}
{"actor":{"display_login":"amitaibu"}}