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.
This commit is contained in:
parent
7f7347faa9
commit
c6b0d9b8d5
2 changed files with 2 additions and 9 deletions
|
|
@ -494,7 +494,6 @@ not ever manually set this.
|
||||||
|
|
||||||
=cut
|
=cut
|
||||||
|
|
||||||
|
|
||||||
sub getGroupsIn {
|
sub getGroupsIn {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $isRecursive = shift;
|
my $isRecursive = shift;
|
||||||
|
|
@ -516,6 +515,8 @@ sub getGroupsIn {
|
||||||
my $gog = WebGUI::Group->new($self->session,$group)->getGroupsIn(1,$loopCount);
|
my $gog = WebGUI::Group->new($self->session,$group)->getGroupsIn(1,$loopCount);
|
||||||
push(@groupsOfGroups, @$gog);
|
push(@groupsOfGroups, @$gog);
|
||||||
}
|
}
|
||||||
|
my %unique = map { $_ => 1 } @groupsOfGroups;
|
||||||
|
@groupsOfGroups = keys %unique;
|
||||||
$gotGroupsInGroup->{recursive}{$self->getId} = \@groupsOfGroups;
|
$gotGroupsInGroup->{recursive}{$self->getId} = \@groupsOfGroups;
|
||||||
return \@groupsOfGroups;
|
return \@groupsOfGroups;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,11 +80,8 @@ ok( ($gA->name eq 'Group A' and $gB->name eq 'Group B'), 'object name assignment
|
||||||
|
|
||||||
$gB->addGroups([$gA->getId]);
|
$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');
|
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');
|
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([$gB->getId], $gA->getGroupsFor() ,'Group B contains Group A');
|
||||||
cmp_bag([3], $gA->getGroupsIn() ,'Admin added to group A automatically');
|
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() ,'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');
|
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 {
|
END {
|
||||||
(defined $gA and ref $gA eq 'WebGUI::Group') and $gA->delete;
|
(defined $gA and ref $gA eq 'WebGUI::Group') and $gA->delete;
|
||||||
(defined $gB and ref $gB eq 'WebGUI::Group') and $gB->delete;
|
(defined $gB and ref $gB eq 'WebGUI::Group') and $gB->delete;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue