fixed: Syndicated Content asset tries too hard to get URLs returning errors

This commit is contained in:
Graham Knop 2008-03-25 21:30:23 +00:00
parent b65defdf03
commit d7680799e2
2 changed files with 24 additions and 18 deletions

View file

@ -22,6 +22,7 @@
- fixed: Collaboration System errors when missing RSS From Parent - fixed: Collaboration System errors when missing RSS From Parent
- fixed: Syndicated Content picks wrong entries for interleaving - fixed: Syndicated Content picks wrong entries for interleaving
- fixed: Syndicated Content URLs using macros not updated by caching workflow - 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 7.5.7
- fixed: HttpProxy mixes original site's content encoding with WebGUI's - fixed: HttpProxy mixes original site's content encoding with WebGUI's

View file

@ -324,23 +324,28 @@ sub _normalize_items {
#------------------------------------------------------------------- #-------------------------------------------------------------------
sub _get_rss_data { sub _get_rss_data {
my $session = shift; my $session = shift;
my $url = shift; my $url = shift;
my $cache = WebGUI::Cache->new($session,'url:' . $url, 'RSS'); my $cache = WebGUI::Cache->new($session,'url:' . $url, 'RSS');
my $rss_serial = $cache->get; my $rss_serial = $cache->get;
my $rss = {}; my $rss = {};
if ($rss_serial) { if ($rss_serial) {
$rss = Storable::thaw($rss_serial); $rss = Storable::thaw($rss_serial);
} else { }
my $ua = LWP::UserAgent->new(timeout => 5); if ($rss->{error}) {
$ua->env_proxy; return undef;
my $response = $ua->get($url); }
if (!$response->is_success()) { else {
$session->errorHandler->warn("Error retrieving url '$url': " . my $ua = LWP::UserAgent->new(timeout => 5);
$response->status_line()); $ua->env_proxy;
return undef; my $response = $ua->get($url);
} if (!$response->is_success()) {
my $xml = $response->content(); $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 # Approximate with current time if we don't have a Last-Modified
# header coming from the RSS source. # header coming from the RSS source.
@ -402,7 +407,7 @@ sub _get_rss_data {
$rss->{last_modified} = $last_modified; $rss->{last_modified} = $last_modified;
#Default to an hour timeout #Default to an hour timeout
$cache->set(Storable::freeze($rss), 3600); $cache->set(Storable::nfreeze($rss), 3600);
} }
return $rss; return $rss;