From c6b0d9b8d52782f33c4a4747fd609f761c2ecf20 Mon Sep 17 00:00:00 2001 From: Colin Kuskie Date: Tue, 14 Mar 2006 05:54:42 +0000 Subject: [PATCH] Remove debug code from Group.t Force uniqueness check inside isInGroups to prevent multiple group definitions from being returned. This should cut the size of the in-memory Group cache by 50%, since group id #3 is returned for _every_ group. --- lib/WebGUI/Group.pm | 3 ++- t/Group.t | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index b4db0437e..45eb40369 100755 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -494,7 +494,6 @@ not ever manually set this. =cut - sub getGroupsIn { my $self = shift; my $isRecursive = shift; @@ -516,6 +515,8 @@ sub getGroupsIn { my $gog = WebGUI::Group->new($self->session,$group)->getGroupsIn(1,$loopCount); push(@groupsOfGroups, @$gog); } + my %unique = map { $_ => 1 } @groupsOfGroups; + @groupsOfGroups = keys %unique; $gotGroupsInGroup->{recursive}{$self->getId} = \@groupsOfGroups; return \@groupsOfGroups; } diff --git a/t/Group.t b/t/Group.t index 54fe7b7e2..57be22db5 100644 --- a/t/Group.t +++ b/t/Group.t @@ -80,11 +80,8 @@ ok( ($gA->name eq 'Group A' and $gB->name eq 'Group B'), 'object name assignment $gB->addGroups([$gA->getId]); -$session->errorHandler->warn('A, B recursive groupsIn'); cmp_bag([$gA->getId, 3], $gB->getGroupsIn(1) ,'Group A is in Group B, recursively'); -$session->errorHandler->warn('A, B regular groupsIn'); cmp_bag([$gA->getId, 3], $gB->getGroupsIn() ,'Group A is in Group B'); -$session->errorHandler->warn('A, B regular groupsFor'); cmp_bag([$gB->getId], $gA->getGroupsFor() ,'Group B contains Group A'); cmp_bag([3], $gA->getGroupsIn() ,'Admin added to group A automatically'); @@ -106,11 +103,6 @@ cmp_bag([3], $gA->getGroupsIn() ,'Group C is a member of Group A, cached'); cmp_bag([$gA->getId, 3], $gB->getGroupsIn() ,'Group A is in Group B, cached result'); cmp_bag([$gA->getId, 3], $gB->getGroupsIn(1) ,'Group C is in Group B, recursively, cached result'); -use Data::Dumper; - -diag("direct: ".Dumper $gB->getGroupsIn()); -diag("recursive: ".Dumper $gB->getGroupsIn(1)); - END { (defined $gA and ref $gA eq 'WebGUI::Group') and $gA->delete; (defined $gB and ref $gB eq 'WebGUI::Group') and $gB->delete;