fixed #12206: Bad Subscription Groups in Duplicated Threads

This commit is contained in:
Paul Driver 2011-07-27 11:18:22 -05:00
parent 5e40bf4528
commit 9738ec0171
3 changed files with 54 additions and 5 deletions

View file

@ -1,4 +1,5 @@
7.10.22
- fixed #12206: Bad Subscription Groups in Duplicated Threads
7.10.21
- added #9668 extension template variable to attachment loops for the following assets:

View file

@ -268,15 +268,17 @@ sub duplicate {
my $self = shift;
my $session = $self->session;
my $copy = $self->SUPER::duplicate(@_);
my $oldGroupId = $self->get('subscriptionGroupId');
my $key = 'subscriptionGroupId';
my $oldGroupId = $self->get($key);
if ($oldGroupId) {
my $newGroup = WebGUI::Group->new($session, 'new');
my $oldGroup = WebGUI::Group->new($session, $oldGroupId);
if ($oldGroup) {
$copy->update({ $key => '' });
$copy->createSubscriptionGroup();
if (my $oldGroup = WebGUI::Group->new($session, $oldGroupId)) {
my $newGroup = WebGUI::Group->new($session, $copy->get($key));
$newGroup->addUsers($oldGroup->getUsers('withoutExpired'));
$newGroup->addGroups($oldGroup->getGroupsIn);
}
$copy->update({subscriptionGroupId => $newGroup->getId});
}
return $copy;
}

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
#------------------------------------------------------------------
=head1 BUG DESCRIPTION
When Thread assets are copied, a new subscription group gets created for them,
but not by calling $thread->createSubscriptionGroup. Instead, a "blank" group
is created, and then the users from the old group are added to it -- which by
default has Admins subscribed in it. So, every time we copy a thread, our
admins start getting spammed with subscription updates.
=cut
use warnings;
use strict;
use Test::More tests => 2;
use Test::Exception;
use FindBin;
use lib "$FindBin::Bin/../../../lib";
use WebGUI::Test;
use WebGUI::Asset;
my $session = WebGUI::Test->session;
my $thread = WebGUI::Asset->getImportNode($session)->addChild(
{
className => 'WebGUI::Asset::Post::Thread',
}
);
WebGUI::Test->addToCleanup($thread);
$thread->createSubscriptionGroup();
my $admin = WebGUI::User->new($session, 3);
ok !$admin->isInGroup($thread->get('subscriptionGroupId'));
$thread = $thread->duplicate();
WebGUI::Test->addToCleanup($thread);
ok !$admin->isInGroup($thread->get('subscriptionGroupId'));