Query problem(tickets req by grp members), RT just hangs

I have the following lines of code in
/Elements/Grprequests the purpose of which is to
display tickets requested by user’s group members(user
can be a member of more than one group), when the page
is loaded RT just hangs(does not die), as if its
trying to run the query:

<%init>
my $Groups = RT::Groups->new($session{‘CurrentUser’});
$Groups->LimitToUserDefinedGroups();
$Groups->WithMember(PrincipalId =>
$session{‘CurrentUser’}->Id);

my $rows = 10;

my $Queues = RT::Queues->new($session{‘CurrentUser’});
$Queues->UnLimit();

my $QueuesListing = ‘’;

my @ids;
my $Group;

while ( $Group = $Groups->Next ) {
push @ids, $Group->Id;
}

while (my $queue = $Queues->Next) {
next unless
($queue->CurrentUserHasRight(‘ShowTicket’));
if ($QueuesListing ne ‘’) {
$QueuesListing .= " OR Queue = ";
} else {
$QueuesListing = “Queue = “;
}
$QueuesListing .= “’”.$queue->Name.”’”;
}

my $Query = “
Requestor != '”.$session{‘CurrentUser’}->Id."'
AND ( Status = ‘new’ OR Status = ‘open’ OR Status =
‘stalled’ )
AND ( RequestorGroup = ‘$ids[0]’ OR RequestorGroup
= ‘$ids[1]’ )
AND ( " . $QueuesListing . " )
";

my $QueryString = ‘?’ .
$m->comp(’/Elements/QueryString’,
Query => $Query,
Order => ‘DESC’,
OrderBy => ‘Priority’) if ($Query);

</%init>

Yahoo! Mail - PC Magazine Editors’ Choice 2005
http://mail.yahoo.com

I have the following lines of code in
/Elements/Grprequests the purpose of which is to
display tickets requested by user’s group members(user
can be a member of more than one group), when the page
is loaded RT just hangs(does not die), as if its
trying to run the query:
You should try to figure out where it hangs. Does it spin in DB or in RT code?
What is in the RT log file? Code looks fine, at least I don’t see any mistakes.

PS: You forgot to specify software versions.

<%init>
my $Groups = RT::Groups->new($session{‘CurrentUser’});
$Groups->LimitToUserDefinedGroups();
$Groups->WithMember(PrincipalId =>
$session{‘CurrentUser’}->Id);

my $rows = 10;

my $Queues = RT::Queues->new($session{‘CurrentUser’});
$Queues->UnLimit();

my $QueuesListing = ‘’;

my @ids;
my $Group;

while ( $Group = $Groups->Next ) {
push @ids, $Group->Id;
}

while (my $queue = $Queues->Next) {
next unless
($queue->CurrentUserHasRight(‘ShowTicket’));
if ($QueuesListing ne ‘’) {
$QueuesListing .= " OR Queue = ";
} else {
$QueuesListing = “Queue = “;
}
$QueuesListing .= “’”.$queue->Name.”’”;
}

my $Query = “
Requestor != '”.$session{‘CurrentUser’}->Id."'
AND ( Status = ‘new’ OR Status = ‘open’ OR Status =
‘stalled’ )
AND ( RequestorGroup = ‘$ids[0]’ OR RequestorGroup
= ‘$ids[1]’ )
AND ( " . $QueuesListing . " )
";

my $QueryString = ‘?’ .
$m->comp(’/Elements/QueryString’,
Query => $Query,
Order => ‘DESC’,
OrderBy => ‘Priority’) if ($Query);

</%init>

Best regards, Ruslan.