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: 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

View file

@ -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;