diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 5038c4443..6853dfd8f 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,7 @@ - fixed #12033: scratch variable problems during export - fixed: Underground label style forces radio buttons and check boxes to render vertically. - fixed #11704: JavaScript::Packer, HTML::Packer, and CSS::Packer use $& variable + - fixed #12038: Incorrect caching of groups with 0 second cache setting (Dale Trexel) 7.10.8 - rfe #12016 for the top story as well diff --git a/lib/WebGUI/Group.pm b/lib/WebGUI/Group.pm index 9dc05b017..94f09b058 100644 --- a/lib/WebGUI/Group.pm +++ b/lib/WebGUI/Group.pm @@ -259,7 +259,9 @@ sub cacheGroupings { $groupMembers->{$userId} = { isMember => $isInGroup }; } - $cache->set($groupMembers, $self->groupCacheTimeout); + if ($self->groupCacheTimeout()) { + $cache->set($groupMembers, $self->groupCacheTimeout); + } } #------------------------------------------------------------------- @@ -630,7 +632,9 @@ sub getAllUsers { } my %users = map { $_ => 1 } @users; @users = keys %users; - $cache->set(\@users, $self->groupCacheTimeout); + if ($self->groupCacheTimeout()) { + $cache->set(\@users, $self->groupCacheTimeout); + } return \@users; } diff --git a/t/Group/group_scratch.t b/t/Group/group_scratch.t new file mode 100644 index 000000000..464487824 --- /dev/null +++ b/t/Group/group_scratch.t @@ -0,0 +1,46 @@ +# vim:syntax=perl +#------------------------------------------------------------------- +# WebGUI is Copyright 2001-2009 Plain Black Corporation. +#------------------------------------------------------------------- +# Please read the legal notices (docs/legal.txt) and the license +# (docs/license.txt) that came with this distribution before using +# this software. +#------------------------------------------------------------------ +# http://www.plainblack.com info@plainblack.com +#------------------------------------------------------------------ + +use FindBin; +use strict; +use lib "$FindBin::Bin/../lib"; +use Test::More; +use WebGUI::Test; # Must use this before any other WebGUI modules +use WebGUI::Session; + +use WebGUI::Group; + +#---------------------------------------------------------------------------- +# Init +my $session = WebGUI::Test->session; + + +#---------------------------------------------------------------------------- +# Tests + +plan tests => 5; # Increment this number for each test you create + +my $group = WebGUI::Group->new($session, 'new'); +WebGUI::Test->addToCleanup($group); +$group->scratchFilter("itchy=test_value"); +is( $group->scratchFilter(), "itchy=test_value",'Group->scratchFilter is properly set and retrieved'); +$group->groupCacheTimeout(0); +is( $group->groupCacheTimeout(), 0, 'set groupCacheTimeout to 0'); + +$session->user({userId => 1}); +ok( !$session->user->isInGroup($group->getId), 'Visitor is NOT in the group BEFORE scratch value is set'); +$session->scratch->set('itchy', 'test_value'); +is ($group->hasScratchUser($session->user->getId), 1, 'Group->hasScratchUser correctly returns 1 immediately after scratch is set'); + +##Simulate another page view by clearing stow, which is volatile +$session->stow->deleteAll; +$session->scratch->delete('itchy'); +is ($group->hasScratchUser($session->user->getId), 0, 'after clearing scratch, user is not in the group any longer');