Fix an issue where the default cache time of WebGUI::Cache would cause Groups with caches disabled (groupCacheTimeout=0) to actually be cached for 60 seconds. Fixes bug #12038.

This commit is contained in:
Colin Kuskie 2011-02-07 13:36:46 -08:00
parent 4a5196ac5c
commit 8aee259282
3 changed files with 53 additions and 2 deletions

View file

@ -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

View file

@ -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;
}

46
t/Group/group_scratch.t Normal file
View file

@ -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');