Skip to content

Commit

Permalink
Make RT::User::OwnGroups() optionally recursive
Browse files Browse the repository at this point in the history
When $SelfServiceShowGroupTickets is set to 1, the My Group Tickets
portlet in self-service would recursively search for all of a user's
group memberships. In some cases, this could degrade search performance
by trying to return tickets belonging to other groups. By making
OwnGroups() optionally recursive, both issues are avoided.
  • Loading branch information
Jason Crome committed Jan 12, 2024
1 parent 3332d26 commit 5f49678
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/RT/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1570,11 +1570,15 @@ user is a member.

sub OwnGroups {
my $self = shift;
my %args = (
Recursively => 1,
@_ # get the real argumentlist
);
my $groups = RT::Groups->new($self->CurrentUser);
$groups->LimitToUserDefinedGroups;
$groups->WithMember(
PrincipalId => $self->Id,
Recursively => 1
Recursively => $args{'Recursively'},
);
return $groups;
}
Expand Down
2 changes: 1 addition & 1 deletion share/html/SelfService/Elements/MyGroupRequests
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ unless ( $ret ){
RT::Logger->error("Unable to load user record for user: " . $session{'CurrentUser'}->Name . " :$msg");
return;
}
my $groups_obj = $user->OwnGroups;
my $groups_obj = $user->OwnGroups( Recursively => 0 );

my $Query = '';

Expand Down

0 comments on commit 5f49678

Please sign in to comment.