{"action":"created","comment":{"url":"https://api.github.com/repos/Wikia/app/pulls/comments/59209237","id":59209237,"diff_hunk":"@@ -283,19 +293,29 @@ private function removeFromLocalGroup( \\User $user, $group ) {\n \t\treturn true;\n \t}\n \n-\tpublic function removeFromGroup( \\User $performer, \\User $userToChange, $group ) {\n-\t\tif ( !$this->canGroupBeRemoved( $performer, $userToChange, $group ) ) {\n-\t\t\treturn false;\n+\tpublic function removeFromGroup( \\User $performer, \\User $userToChange, $groups )\n+\t{\n+\t\t$groupList = $groups;\n+\t\tif ( !is_array( $groups ) ) {\n+\t\t\t$groupList = [ $groups ];\n \t\t}\n \n-\t\ttry {\n-\t\t\tif ( in_array( $group, $this->permissionsConfiguration->getGlobalGroups() ) ) {\n-\t\t\t\t$result = $this->removeFromGlobalGroup( $userToChange, $group );\n-\t\t\t} else {\n-\t\t\t\t$result = $this->removeFromLocalGroup( $userToChange, $group );\n+\t\t//First check if we can remove all groups (if we remove in parallel to checking, then the check may not be valid)\n+\t\tforeach ( $groupList as $group ) {\n+\t\t\tif ( !$this->canGroupBeRemoved( $performer, $userToChange, $group ) ) {\n+\t\t\t\treturn false;\n \t\t\t}\n \t\t}\n-\t\tfinally {\n+\t\t$result = true;\n+\t\ttry {\n+\t\t\tforeach ( $groupList as $group ) {\n+\t\t\t\tif ( in_array( $group, $this->permissionsConfiguration->getGlobalGroups() ) ) {\n+\t\t\t\t\t$result = $this->removeFromGlobalGroup( $userToChange, $group ) && $result;\n+\t\t\t\t} else {\n+\t\t\t\t\t$result = $this->removeFromLocalGroup( $userToChange, $group ) && $result;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t} finally {","path":"lib/Wikia/src/Service/User/Permissions/PermissionsServiceImpl.php","position":69,"original_position":69,"commit_id":"8aeee86cbd5bb52f7e60e573b3e4e96dd7e04bb2","original_commit_id":"8aeee86cbd5bb52f7e60e573b3e4e96dd7e04bb2","user":{"login":"macbre","id":1929317,"avatar_url":"https://avatars.githubusercontent.com/u/1929317?v=3","gravatar_id":"","url":"https://api.github.com/users/macbre","html_url":"https://github.com/macbre","followers_url":"https://api.github.com/users/macbre/followers","following_url":"https://api.github.com/users/macbre/following{/other_user}","gists_url":"https://api.github.com/users/macbre/gists{/gist_id}","starred_url":"https://api.github.com/users/macbre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/macbre/subscriptions","organizations_url":"https://api.github.com/users/macbre/orgs","repos_url":"https://api.github.com/users/macbre/repos","events_url":"https://api.github.com/users/macbre/events{/privacy}","received_events_url":"https://api.github.com/users/macbre/received_events","type":"User","site_admin":false},"body":"Can safely ignore exceptions caught inside this `try` block?","created_at":"2016-04-11T14:06:35Z","updated_at":"2016-04-11T14:06:35Z","html_url":"https://github.com/Wikia/app/pull/10199#discussion_r59209237","pull_request_url":"https://api.github.com/repos/Wikia/app/pulls/10199","_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments/59209237"},"html":{"href":"https://github.com/Wikia/app/pull/10199#discussion_r59209237"},"pull_request":{"href":"https://api.github.com/repos/Wikia/app/pulls/10199"}}},"pull_request":{"url":"https://api.github.com/repos/Wikia/app/pulls/10199","id":65977511,"html_url":"https://github.com/Wikia/app/pull/10199","diff_url":"https://github.com/Wikia/app/pull/10199.diff","patch_url":"https://github.com/Wikia/app/pull/10199.patch","issue_url":"https://api.github.com/repos/Wikia/app/issues/10199","number":10199,"state":"open","locked":false,"title":"[PLATFORM-2011] Fixed changing list of groups","user":{"login":"jcellary","id":7473307,"avatar_url":"https://avatars.githubusercontent.com/u/7473307?v=3","gravatar_id":"","url":"https://api.github.com/users/jcellary","html_url":"https://github.com/jcellary","followers_url":"https://api.github.com/users/jcellary/followers","following_url":"https://api.github.com/users/jcellary/following{/other_user}","gists_url":"https://api.github.com/users/jcellary/gists{/gist_id}","starred_url":"https://api.github.com/users/jcellary/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jcellary/subscriptions","organizations_url":"https://api.github.com/users/jcellary/orgs","repos_url":"https://api.github.com/users/jcellary/repos","events_url":"https://api.github.com/users/jcellary/events{/privacy}","received_events_url":"https://api.github.com/users/jcellary/received_events","type":"User","site_admin":false},"body":"https://wikia-inc.atlassian.net/browse/PLATFORM-2011\r\n\r\nAdded possibility to add/remove list of groups instead of a single value due to an edge case that when removing rights one by one, one can lack permissions to remove the next group because of removal of a previous one. Now all validation is done first and then actual removal takes place.","created_at":"2016-04-11T11:22:56Z","updated_at":"2016-04-11T14:06:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"64bb1d44f30fdd8a5468bc0403e3dc57e58e59b3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/Wikia/app/pulls/10199/commits","review_comments_url":"https://api.github.com/repos/Wikia/app/pulls/10199/comments","review_comment_url":"https://api.github.com/repos/Wikia/app/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Wikia/app/issues/10199/comments","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/8aeee86cbd5bb52f7e60e573b3e4e96dd7e04bb2","head":{"label":"Wikia:platform-2011-rights-fix","ref":"platform-2011-rights-fix","sha":"8aeee86cbd5bb52f7e60e573b3e4e96dd7e04bb2","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","deployments_url":"https://api.github.com/repos/Wikia/app/deployments","created_at":"2012-08-23T20:55:58Z","updated_at":"2016-04-06T08:17:14Z","pushed_at":"2016-04-11T14:00:27Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":693827,"stargazers_count":96,"watchers_count":96,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":78,"mirror_url":null,"open_issues_count":96,"forks":78,"open_issues":96,"watchers":96,"default_branch":"dev"}},"base":{"label":"Wikia:dev","ref":"dev","sha":"e3bfbf8a7cbda4aefa7b18275cad3779ab131f21","user":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"repo":{"id":5532313,"name":"app","full_name":"Wikia/app","owner":{"login":"Wikia","id":1171011,"avatar_url":"https://avatars.githubusercontent.com/u/1171011?v=3","gravatar_id":"","url":"https://api.github.com/users/Wikia","html_url":"https://github.com/Wikia","followers_url":"https://api.github.com/users/Wikia/followers","following_url":"https://api.github.com/users/Wikia/following{/other_user}","gists_url":"https://api.github.com/users/Wikia/gists{/gist_id}","starred_url":"https://api.github.com/users/Wikia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wikia/subscriptions","organizations_url":"https://api.github.com/users/Wikia/orgs","repos_url":"https://api.github.com/users/Wikia/repos","events_url":"https://api.github.com/users/Wikia/events{/privacy}","received_events_url":"https://api.github.com/users/Wikia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Wikia/app","description":"Wikia Application Code","fork":false,"url":"https://api.github.com/repos/Wikia/app","forks_url":"https://api.github.com/repos/Wikia/app/forks","keys_url":"https://api.github.com/repos/Wikia/app/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Wikia/app/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Wikia/app/teams","hooks_url":"https://api.github.com/repos/Wikia/app/hooks","issue_events_url":"https://api.github.com/repos/Wikia/app/issues/events{/number}","events_url":"https://api.github.com/repos/Wikia/app/events","assignees_url":"https://api.github.com/repos/Wikia/app/assignees{/user}","branches_url":"https://api.github.com/repos/Wikia/app/branches{/branch}","tags_url":"https://api.github.com/repos/Wikia/app/tags","blobs_url":"https://api.github.com/repos/Wikia/app/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Wikia/app/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Wikia/app/git/refs{/sha}","trees_url":"https://api.github.com/repos/Wikia/app/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Wikia/app/statuses/{sha}","languages_url":"https://api.github.com/repos/Wikia/app/languages","stargazers_url":"https://api.github.com/repos/Wikia/app/stargazers","contributors_url":"https://api.github.com/repos/Wikia/app/contributors","subscribers_url":"https://api.github.com/repos/Wikia/app/subscribers","subscription_url":"https://api.github.com/repos/Wikia/app/subscription","commits_url":"https://api.github.com/repos/Wikia/app/commits{/sha}","git_commits_url":"https://api.github.com/repos/Wikia/app/git/commits{/sha}","comments_url":"https://api.github.com/repos/Wikia/app/comments{/number}","issue_comment_url":"https://api.github.com/repos/Wikia/app/issues/comments{/number}","contents_url":"https://api.github.com/repos/Wikia/app/contents/{+path}","compare_url":"https://api.github.com/repos/Wikia/app/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Wikia/app/merges","archive_url":"https://api.github.com/repos/Wikia/app/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Wikia/app/downloads","issues_url":"https://api.github.com/repos/Wikia/app/issues{/number}","pulls_url":"https://api.github.com/repos/Wikia/app/pulls{/number}","milestones_url":"https://api.github.com/repos/Wikia/app/milestones{/number}","notifications_url":"https://api.github.com/repos/Wikia/app/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Wikia/app/labels{/name}","releases_url":"https://api.github.com/repos/Wikia/app/releases{/id}","deployments_url":"https://api.github.com/repos/Wikia/app/deployments","created_at":"2012-08-23T20:55:58Z","updated_at":"2016-04-06T08:17:14Z","pushed_at":"2016-04-11T14:00:27Z","git_url":"git://github.com/Wikia/app.git","ssh_url":"git@github.com:Wikia/app.git","clone_url":"https://github.com/Wikia/app.git","svn_url":"https://github.com/Wikia/app","homepage":"http://dev.wikia.com","size":693827,"stargazers_count":96,"watchers_count":96,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":78,"mirror_url":null,"open_issues_count":96,"forks":78,"open_issues":96,"watchers":96,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/Wikia/app/pulls/10199"},"html":{"href":"https://github.com/Wikia/app/pull/10199"},"issue":{"href":"https://api.github.com/repos/Wikia/app/issues/10199"},"comments":{"href":"https://api.github.com/repos/Wikia/app/issues/10199/comments"},"review_comments":{"href":"https://api.github.com/repos/Wikia/app/pulls/10199/comments"},"review_comment":{"href":"https://api.github.com/repos/Wikia/app/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Wikia/app/pulls/10199/commits"},"statuses":{"href":"https://api.github.com/repos/Wikia/app/statuses/8aeee86cbd5bb52f7e60e573b3e4e96dd7e04bb2"}}}}