From 5f4967890188ddb9c526ab158a5b33ac77a2e3cd Mon Sep 17 00:00:00 2001 From: Jason Crome <jcrome@bestpractical.com> Date: Fri, 12 Jan 2024 14:39:38 -0500 Subject: [PATCH] Make RT::User::OwnGroups() optionally recursive 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. --- lib/RT/User.pm | 6 +++++- share/html/SelfService/Elements/MyGroupRequests | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/RT/User.pm b/lib/RT/User.pm index 4a881003bca..cde2b5a17d2 100644 --- a/lib/RT/User.pm +++ b/lib/RT/User.pm @@ -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; } diff --git a/share/html/SelfService/Elements/MyGroupRequests b/share/html/SelfService/Elements/MyGroupRequests index 96d730a7834..68ad9519c92 100644 --- a/share/html/SelfService/Elements/MyGroupRequests +++ b/share/html/SelfService/Elements/MyGroupRequests @@ -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 = '';