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:
parent
eaa29c5f44
commit
3fe8f9a080
3 changed files with 30 additions and 3 deletions
|
|
@ -1,4 +1,6 @@
|
||||||
7.10.25
|
7.10.25
|
||||||
|
- fixed: if user1 adds user2 as a friend, user2 doesn't see user1 as a friend
|
||||||
|
- fixed: data sync bug in WebGUI::User::friends
|
||||||
- added: group() function for Survey::ExpressionEngine to test group membership
|
- added: group() function for Survey::ExpressionEngine to test group membership
|
||||||
- added: give WebGUI::PseudoRequest a hostname method
|
- added: give WebGUI::PseudoRequest a hostname method
|
||||||
- fixed: don't clobber the request handler if WebGUI::Test was loaded inside of mod_perl
|
- fixed: don't clobber the request handler if WebGUI::Test was loaded inside of mod_perl
|
||||||
|
|
|
||||||
|
|
@ -527,11 +527,18 @@ sub friends {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my $myFriends;
|
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 the user already has a friend group fetch it.
|
||||||
if ( $self->{_user}{"friendsGroup"} ne "" ) {
|
if ( $self->{_user}{friendsGroup} ) {
|
||||||
if ( ! exists $self->{_friendsGroup} ) {
|
if ( ! exists $self->{_friendsGroup} ) {
|
||||||
# Friends group is not in cache, so instantiate and cache it.
|
# 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;
|
$self->{_friendsGroup} = $myFriends;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
20
t/User.t
20
t/User.t
|
|
@ -22,7 +22,7 @@ use WebGUI::User;
|
||||||
use WebGUI::ProfileField;
|
use WebGUI::ProfileField;
|
||||||
use WebGUI::Shop::AddressBook;
|
use WebGUI::Shop::AddressBook;
|
||||||
|
|
||||||
use Test::More tests => 235; # increment this value for each test you create
|
use Test::More tests => 237; # increment this value for each test you create
|
||||||
use Test::Deep;
|
use Test::Deep;
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
|
|
||||||
|
|
@ -753,6 +753,24 @@ undef $friendsGroup2;
|
||||||
undef $friendsGroup3;
|
undef $friendsGroup3;
|
||||||
undef $neighborClone;
|
undef $neighborClone;
|
||||||
|
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
# friend reciprication
|
||||||
|
#
|
||||||
|
################################################################
|
||||||
|
#
|
||||||
|
|
||||||
|
my $buddy1 = WebGUI::User->new($session, 'new');
|
||||||
|
WebGUI::Test->addToCleanup($buddy1);
|
||||||
|
|
||||||
|
my $buddy2 = WebGUI::User->new($session, 'new');
|
||||||
|
WebGUI::Test->addToCleanup($buddy2);
|
||||||
|
|
||||||
|
WebGUI::Friends->new( $session, $buddy1 )->add( [ $buddy2->userId ] );
|
||||||
|
|
||||||
|
ok( exists $buddy1->friends->getUserList->{ $buddy2->userId }, 'buddy1 has buddy2 in his friends list' );
|
||||||
|
ok( exists $buddy2->friends->getUserList->{ $buddy1->userId }, 'buddy2 has buddy1 in his friends list' );
|
||||||
|
|
||||||
################################################################
|
################################################################
|
||||||
#
|
#
|
||||||
# acceptsPrivateMessages
|
# acceptsPrivateMessages
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue