From aec48fa2271f4b53ff67557a4067fcc97c751b01 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Wed, 26 Sep 2007 09:44:59 +0000 Subject: [PATCH] fix newsletter containing duplicate threads --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Workflow/Activity/SendNewsletters.pm | 4 ++++ 2 files changed, 5 insertions(+) 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");