diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 518e221ca..0ad32dde9 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -1,6 +1,7 @@ 7.4.8 - fix: Syndicated Content doesn't display all items with multiple feeds in interleaved mode - fix: SQLForm file upload broken + - fix: Newsletter can contain duplicate threads 7.4.7 - fix: misspelled i18n in webgui password recovery diff --git a/lib/WebGUI/Workflow/Activity/SendNewsletters.pm b/lib/WebGUI/Workflow/Activity/SendNewsletters.pm index 67a94f354..1ef014fc9 100644 --- a/lib/WebGUI/Workflow/Activity/SendNewsletters.pm +++ b/lib/WebGUI/Workflow/Activity/SendNewsletters.pm @@ -99,6 +99,7 @@ sub execute { # find matching threads my @threads = (); + my %foundThreads; $eh->info("Find threads in $assetId matching $userId subscriptions."); foreach my $subscription (split("\n", $subscriptions)) { $eh->info("Found subscription $subscription"); @@ -109,10 +110,13 @@ sub execute { and className like ? and lineage like ? and state = ?", [$fieldId, '%'.$value.'%', $lastTimeSent, 'WebGUI::Asset::Post::Thread%', $newsletter->get("lineage").'%', 'published']); while (my ($threadId) = $matchingThreads->array) { + next + if $foundThreads{$threadId}; my $thread = WebGUI::Asset->new($self->session, $threadId); if (defined $thread) { $eh->info("Found thread $threadId"); push(@threads, $thread); + $foundThreads{$threadId} = 1; } else { $eh->error("Couldn't instanciate thread $threadId");