From 0bf48f934912a2c82219d7b3e26161988854d11e Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 25 Mar 2008 20:07:23 +0000 Subject: [PATCH] fixed: Syndicated Content picks wrong entries for interleaving --- docs/changelog/7.x.x.txt | 1 + docs/upgrades/upgrade_7.5.7-7.5.8.pl | 9 ++++++ lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 32 ++++++++----------- 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index f06e0a518..ac41723f4 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -20,6 +20,7 @@ - fixed: Bad message if database link for SQL Report doesn't exist - fixed: Thingy shows things from other Thingies - fixed: Collaboration System errors when missing RSS From Parent + - fixed: Syndicated Content picks wrong entries for interleaving 7.5.7 - fixed: HttpProxy mixes original site's content encoding with WebGUI's diff --git a/docs/upgrades/upgrade_7.5.7-7.5.8.pl b/docs/upgrades/upgrade_7.5.7-7.5.8.pl index 1921be275..67c00fd6d 100644 --- a/docs/upgrades/upgrade_7.5.7-7.5.8.pl +++ b/docs/upgrades/upgrade_7.5.7-7.5.8.pl @@ -37,6 +37,15 @@ finish($session); # this line required # # and here's our code #} +#------------------------------------------------- +sub clearRSSCache { + my $session = shift; + print "\tClearing RSS feed cache..." unless $quiet; + my $cache = WebGUI::Cache->new($session, '', 'RSS'); + $cache->flush; + print " Done.\n" unless $quiet; +} + #---------------------------------------------------------------------------- sub removeOldGalleryColumns { my $session = shift; diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 2df415bee..02781b0d4 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -466,27 +466,21 @@ sub _create_grouped_items{ # No need to return because we're doing everything by reference. sub _create_interleaved_items { - my($items,$rss_feeds,$maxHeadlines,$hasTermsRegex)=@_; - my $items_remain = 1; - while((@$items < $maxHeadlines) && $items_remain){ - $items_remain=0; - foreach my $rss(@$rss_feeds){ - if(defined $rss->{items} - && @$items < $maxHeadlines - && (my $item = shift @{$rss->{items}}) - ){ - $item->{site_title}=$rss->{channel}->{title}; - $item->{site_link}=$rss->{channel}->{link}; - if(! $hasTermsRegex || _check_hasTerms($item,$hasTermsRegex)){ - push @{$items},$item; - } - if (@{$rss->{items}}) { - $items_remain = 1; - } - } - } + my ($items, $rss_feeds, $maxHeadlines, $hasTermsRegex) = @_; + # put all items together into a single list + foreach my $rss (@$rss_feeds) { + while (my $item = shift @{$rss->{items}}) { + if ($hasTermsRegex && ! _check_hasTerms($item, $hasTermsRegex)) { + next; + } + $item->{site_title} = $rss->{channel}->{title}; + $item->{site_link} = $rss->{channel}->{link}; + push @$items, $item; + } } @$items = sort { $b->{date} <=> $a->{date} } @$items; + # limit to $maxHeadlines + @$items = @$items[0 .. ($maxHeadlines - 1)]; } #-------------------------------------------------------------------