diff --git a/core/docs/changelog.txt b/core/docs/changelog.txt index 92be4590e5c..b806bd092d5 100755 --- a/core/docs/changelog.txt +++ b/core/docs/changelog.txt @@ -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 diff --git a/core/model/modx/xmlrss/rssfetch.class.php b/core/model/modx/xmlrss/rssfetch.class.php index 1feb2688b74..827f2d6ea68 100644 --- a/core/model/modx/xmlrss/rssfetch.class.php +++ b/core/model/modx/xmlrss/rssfetch.class.php @@ -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) { @@ -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' diff --git a/manager/controllers/default/dashboard/widget.modx-news.php b/manager/controllers/default/dashboard/widget.modx-news.php index b93b89cbc7e..cb315b7a5fe 100644 --- a/manager/controllers/default/dashboard/widget.modx-news.php +++ b/manager/controllers/default/dashboard/widget.modx-news.php @@ -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'; \ No newline at end of file +return 'modDashboardWidgetNewsFeed'; diff --git a/manager/controllers/default/dashboard/widget.modx-security.php b/manager/controllers/default/dashboard/widget.modx-security.php index 49c301f7eae..1a4cbfd5119 100644 --- a/manager/controllers/default/dashboard/widget.modx-security.php +++ b/manager/controllers/default/dashboard/widget.modx-security.php @@ -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'; \ No newline at end of file +return 'modDashboardWidgetSecurityFeed';