Skip to content

Commit

Permalink
[modxcms#6138] Handle offline errors in RSS feeds
Browse files Browse the repository at this point in the history
Merge remote-tracking branch 'fireproofsocks/master' into bug-6138

* fireproofsocks/master:
  Fixed offline problem described in http://tracker.modx.com/issues/6138
  • Loading branch information
opengeek committed Jun 3, 2013
2 parents dba0d36 + 44f3b7f commit 23443e3
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
1 change: 1 addition & 0 deletions core/docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
This file shows the changes in recent releases of MODX. The most current release is usually the
development release, and is only shown to give an idea of what's currently in the pipeline.

- [#6138] Handle offline errors in RSS feeds
- Refresh file tree after removing file
- [#9946] Do not cache modResource::$_isForward
- Force browser to root on Media Source change
Expand Down
6 changes: 5 additions & 1 deletion core/model/modx/xmlrss/rssfetch.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function fetch_rss ($url) {

$resp = _fetch_remote_file( $url, $request_headers );

if (isset($resp) and $resp) {
if ($resp) {
if ($resp->status == '304' ) {
// we have the most current copy
if ( MAGPIE_DEBUG > 1) {
Expand All @@ -187,6 +187,10 @@ function fetch_rss ($url) {
if ( $resp->status == '-100' ) {
$errormsg .= "(Request timed out after " . MAGPIE_FETCH_TIME_OUT . " seconds)";
}
elseif ( $resp->status == '0' ) {
// you sir, are offline
return false;
}
elseif ( $resp->error ) {
# compensate for Snoopy's annoying habbit to tacking
# on '\n'
Expand Down
12 changes: 7 additions & 5 deletions manager/controllers/default/dashboard/widget.modx-news.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ public function render() {
$newsEnabled = $this->modx->getOption('feed_modx_news_enabled',null,true);
if (!empty($url) && !empty($newsEnabled)) {
$rss = $this->rss->parse($url);
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
if (is_object($rss)) {
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
}
}
}
return implode("\n",$o);
}
}
return 'modDashboardWidgetNewsFeed';
return 'modDashboardWidgetNewsFeed';
12 changes: 7 additions & 5 deletions manager/controllers/default/dashboard/widget.modx-security.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,15 @@ public function render() {
$newsEnabled = $this->modx->getOption('feed_modx_security_enabled',null,true);
if (!empty($url) && !empty($newsEnabled)) {
$rss = $this->rss->parse($url);
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
if (is_object($rss)) {
foreach (array_keys($rss->items) as $key) {
$item= &$rss->items[$key];
$item['pubdate'] = strftime('%c',$item['date_timestamp']);
$o[] = $this->getFileChunk('dashboard/rssitem.tpl',$item);
}
}
}
return implode("\n",$o);
}
}
return 'modDashboardWidgetSecurityFeed';
return 'modDashboardWidgetSecurityFeed';

0 comments on commit 23443e3

Please sign in to comment.