Skip to content

Commit 073093e

Browse files
committedAug 23, 2011
Avoid autivivifying hashes that are live references or will be cached later in User/Group.
1 parent 71a015a commit 073093e

File tree

1 file changed

+10
-14
lines changed

1 file changed

+10
-14
lines changed
 

‎lib/WebGUI/User.pm

+10-14
Original file line numberDiff line numberDiff line change
@@ -954,21 +954,17 @@ sub isInGroup {
954954
### Check stow before we check the cache. Stow is in memory and much faster
955955
my $stow = $session->stow->get("isInGroup", { noclone => 1 }) || {};
956956
return $stow->{$uid}->{$gid} if (exists $stow->{$uid}->{$gid});
957-
957+
958958
### Don't bother checking File Cache if we already have a stow for this group.
959959
### We can find what we need there and save ourselves a bunch of time
960-
my $cache = undef;
961-
my $groupMembers = undef;
962-
unless ($stow->{$uid}->{$gid}) {
963-
$cache = WebGUI::Cache->new($session,["groupMembers",$gid]);
964-
$groupMembers = $cache->get || {};
965-
#If we have this user's membership cached, return what we have stored
966-
if (exists $groupMembers->{$uid}) {
967-
return $groupMembers->{$uid}->{isMember} if (!$self->isVisitor);
968-
return $groupMembers->{$uid}->{$session->getId}->{isMember} #Include the session check for visitors
969-
}
970-
}
971-
960+
my $cache = WebGUI::Cache->new($session,["groupMembers",$gid]);
961+
my $groupMembers = $cache->get || {};
962+
#If we have this user's membership cached, return what we have stored
963+
if (exists $groupMembers->{$uid}) {
964+
return $groupMembers->{$uid}->{isMember} if (!$self->isVisitor);
965+
return $groupMembers->{$uid}->{$session->getId}->{isMember} if exists $groupMembers->{$uid}->{$session->getId}; #Include the session check for visitors
966+
}
967+
972968
### Instantiate the group
973969
my $group = WebGUI::Group->new($session,$gid);
974970
if ( !$group ) {
@@ -978,7 +974,7 @@ sub isInGroup {
978974

979975
#Check the group for membership
980976
my $isInGroup = $group->hasUser($self);
981-
977+
982978
#Write what we found to file cache
983979
$group->cacheGroupings( $self, $isInGroup, $cache, $groupMembers );
984980
return $isInGroup;

0 commit comments

Comments
 (0)
Please sign in to comment.