summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extensions/PhabBugz/lib/Feed.pm29
-rw-r--r--extensions/PhabBugz/lib/User.pm16
2 files changed, 28 insertions, 17 deletions
diff --git a/extensions/PhabBugz/lib/Feed.pm b/extensions/PhabBugz/lib/Feed.pm
index d238c6a43..7d6b4e0ed 100644
--- a/extensions/PhabBugz/lib/Feed.pm
+++ b/extensions/PhabBugz/lib/Feed.pm
@@ -322,20 +322,27 @@ 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 project members for " . $project->name);
- my $set_members = $self->get_group_members( $group );
- my @set_member_phids = uniq map { $_->phid } (@$set_members, $phab_user);
+ INFO( "Checking project members for " . $project->name );
+ my $set_members = $self->get_group_members($group);
+ my @set_member_phids = uniq map { $_->phid } ( @$set_members, $phab_user );
my @current_member_phids = uniq map { $_->phid } @{ $project->members };
- my ($added, $removed) = diff_arrays(\@set_member_phids, \@current_member_phids);
+ my ( $removed, $added ) = diff_arrays( \@current_member_phids, \@set_member_phids );
- INFO('Adding members: ' . join( ',', @$added ));
- $project->add_member( $_ ) foreach @$added;
- INFO('Removing members: ' . join( ',', @$removed ));
- $project->remove_member( $_ ) foreach @$removed;
+ if (@$added) {
+ INFO( 'Adding project members: ' . join( ',', @$added ) );
+ $project->add_member($_) foreach @$added;
+ }
+
+ if (@$removed) {
+ INFO( 'Removing project members: ' . join( ',', @$removed ) );
+ $project->remove_member($_) foreach @$removed;
+ }
- my $result = $project->update();
- local Bugzilla::Logging->fields->{api_result} = $result;
- INFO("Project " . $project->name . " updated");
+ if (@$added || @$removed) {
+ my $result = $project->update();
+ local Bugzilla::Logging->fields->{api_result} = $result;
+ INFO( "Project " . $project->name . " updated" );
+ }
}
}
diff --git a/extensions/PhabBugz/lib/User.pm b/extensions/PhabBugz/lib/User.pm
index 9d4e9eef4..1bf1a842d 100644
--- a/extensions/PhabBugz/lib/User.pm
+++ b/extensions/PhabBugz/lib/User.pm
@@ -131,14 +131,18 @@ sub match {
attachments => { 'external-accounts' => 1 }
};
+ # We can only fetch 100 users at a time so we need to do this in lumps
my $phab_users = [];
- my $result = request( 'user.search', $data );
-
- if ( exists $result->{result}{data} && @{ $result->{result}{data} } ) {
- foreach my $user ( @{ $result->{result}{data} } ) {
- push @$phab_users, $class->new($user);
+ my $result;
+ do {
+ $result = request( 'user.search', $data );
+ if ( exists $result->{result}{data} && @{ $result->{result}{data} } ) {
+ foreach my $user ( @{ $result->{result}{data} } ) {
+ push @$phab_users, $class->new($user);
+ }
}
- }
+ $data->{after} = $result->{cursor}->{after};
+ } while ($result->{cursor}->{after});
return $phab_users;
}