diff options
author | dklawren <dklawren@users.noreply.github.com> | 2018-07-02 23:09:16 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-07-02 23:09:16 +0200 |
commit | 3cc222bb9a02ff33e5296a5d257d49173f656506 (patch) | |
tree | 4bd3f509558913cf95b9cd8a9af891eeeaa0034a /extensions | |
parent | 67e60015450b4e80dcc5fe2f26374b5ea41a0657 (diff) | |
download | bugzilla-3cc222bb9a02ff33e5296a5d257d49173f656506.tar.gz bugzilla-3cc222bb9a02ff33e5296a5d257d49173f656506.tar.xz |
Bug 1472326 - group member syncing is currently broken on production bmo
Diffstat (limited to 'extensions')
-rw-r--r-- | extensions/PhabBugz/lib/Feed.pm | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm index 41a330787..c46d36c13 100644 --- a/extensions/PhabBugz/lib/Feed.pm +++ b/extensions/PhabBugz/lib/Feed.pm @@ -322,9 +322,10 @@ sub group_query { # Make sure phab-bot also a member of the new project group so that it can # make policy changes to the private revisions - INFO("Setting group members for " . $project->name); - my @group_members = $self->get_group_members( $group ); - $project->set_members( [ ($phab_user, @group_members) ] ); + INFO("Setting project members for " . $project->name); + my $set_members = $self->get_group_members( $group ); + push @$set_members, $phab_user unless grep $_->phid eq $phab_user->phid, @$set_members; + $project->set_members( $set_members ); $project->update(); } } @@ -780,25 +781,24 @@ sub get_group_members { my $group_obj = ref $group ? $group : Bugzilla::Group->check( { name => $group, cache => 1 } ); - my $members_all = $group_obj->members_complete(); - my @userids; - foreach my $name ( keys %$members_all ) { - foreach my $user ( @{ $members_all->{$name} } ) { - push @userids, $user->id; - } - } + my $flat_list = join(',', + @{ Bugzilla::Group->flatten_group_membership( $group_obj->id ) } ); - return if !@userids; + my $user_query = " + SELECT DISTINCT profiles.userid + FROM profiles, user_group_map AS ugm + WHERE ugm.user_id = profiles.userid + AND ugm.isbless = 0 + AND ugm.group_id IN($flat_list)"; + my $user_ids = Bugzilla->dbh->selectcol_arrayref($user_query); - # Look up the phab ids for these users - my $phab_users = Bugzilla::Extension::PhabBugz::User->match( + # Return matching users in Phabricator + return Bugzilla::Extension::PhabBugz::User->match( { - ids => \@userids + ids => $user_ids } ); - - return map { $_->phid } @$phab_users; } 1; |