fix nasty data sync bug in WebGUI::User::friends that was causing the friendsGroup assigned to a user t

o immediately be lost and replaced a different one in a call to WebGUI::Friends->add, which creates sep
erate instances of users
This commit is contained in:
Scott Walters 2012-06-19 18:04:12 -04:00
parent eaa29c5f44
commit 3fe8f9a080
3 changed files with 30 additions and 3 deletions

View file

@ -527,11 +527,18 @@ sub friends {
my $self = shift;
my $myFriends;
# did another copy of this object just get a friends group?
$self->{_user}{friendsGroup} ||= $self->session->db->quickScalar(qq{
select friendsGroup from users where userId = ?
}, [
$self->getId,
]);
# If the user already has a friend group fetch it.
if ( $self->{_user}{"friendsGroup"} ne "" ) {
if ( $self->{_user}{friendsGroup} ) {
if ( ! exists $self->{_friendsGroup} ) {
# Friends group is not in cache, so instantiate and cache it.
$myFriends = WebGUI::Group->new($self->session, $self->{_user}{"friendsGroup"});
$myFriends = WebGUI::Group->new($self->session, $self->{_user}{friendsGroup});
$self->{_friendsGroup} = $myFriends;
}
else {