From d7680799e2da5ed426034e482c2380f2a5672985 Mon Sep 17 00:00:00 2001 From: Graham Knop Date: Tue, 25 Mar 2008 21:30:23 +0000 Subject: [PATCH] fixed: Syndicated Content asset tries too hard to get URLs returning errors --- docs/changelog/7.x.x.txt | 1 + lib/WebGUI/Asset/Wobject/SyndicatedContent.pm | 41 +++++++++++-------- 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index b12d8278f..8bd971c21 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -22,6 +22,7 @@ - fixed: Collaboration System errors when missing RSS From Parent - fixed: Syndicated Content picks wrong entries for interleaving - fixed: Syndicated Content URLs using macros not updated by caching workflow + - fixed: Syndicated Content asset tries too hard to get URLs returning errors 7.5.7 - fixed: HttpProxy mixes original site's content encoding with WebGUI's diff --git a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm index 02781b0d4..270a6245d 100644 --- a/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm +++ b/lib/WebGUI/Asset/Wobject/SyndicatedContent.pm @@ -324,23 +324,28 @@ sub _normalize_items { #------------------------------------------------------------------- sub _get_rss_data { - my $session = shift; - my $url = shift; - my $cache = WebGUI::Cache->new($session,'url:' . $url, 'RSS'); - my $rss_serial = $cache->get; - my $rss = {}; - if ($rss_serial) { - $rss = Storable::thaw($rss_serial); - } else { - my $ua = LWP::UserAgent->new(timeout => 5); - $ua->env_proxy; - my $response = $ua->get($url); - if (!$response->is_success()) { - $session->errorHandler->warn("Error retrieving url '$url': " . - $response->status_line()); - return undef; - } - my $xml = $response->content(); + my $session = shift; + my $url = shift; + my $cache = WebGUI::Cache->new($session,'url:' . $url, 'RSS'); + my $rss_serial = $cache->get; + my $rss = {}; + if ($rss_serial) { + $rss = Storable::thaw($rss_serial); + } + if ($rss->{error}) { + return undef; + } + else { + my $ua = LWP::UserAgent->new(timeout => 5); + $ua->env_proxy; + my $response = $ua->get($url); + if (!$response->is_success()) { + $session->errorHandler->warn("Error retrieving url '$url': " . + $response->status_line()); + $cache->set(Storable::nfreeze({'error' => 1, 'error_status' => $response->status_line}), 3600); + return undef; + } + my $xml = $response->content(); # Approximate with current time if we don't have a Last-Modified # header coming from the RSS source. @@ -402,7 +407,7 @@ sub _get_rss_data { $rss->{last_modified} = $last_modified; #Default to an hour timeout - $cache->set(Storable::freeze($rss), 3600); + $cache->set(Storable::nfreeze($rss), 3600); } return $rss;