Handle failing to fetch blog posts. Fixes #1878
This commit is contained in:
@@ -67,9 +67,11 @@ class DashboardController extends Controller
|
||||
$components = Component::orderBy('order')->get();
|
||||
$incidents = $this->getIncidents();
|
||||
$subscribers = $this->getSubscribers();
|
||||
$feed = $this->feed->entries();
|
||||
|
||||
$entries = array_slice($feed->channel->item, 0, 5);
|
||||
$entries = null;
|
||||
if ($feed = $this->feed->entries()) {
|
||||
$entries = array_slice($feed->channel->item, 0, 5);
|
||||
}
|
||||
|
||||
return View::make('dashboard.index')
|
||||
->withPageTitle(trans('dashboard.dashboard'))
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
namespace CachetHQ\Cachet\Integrations;
|
||||
|
||||
use GuzzleHttp\Client;
|
||||
use Exception;
|
||||
use Illuminate\Contracts\Cache\Repository;
|
||||
|
||||
/**
|
||||
@@ -63,12 +64,16 @@ class Feed
|
||||
*/
|
||||
public function entries()
|
||||
{
|
||||
return $this->cache->remember('feeds', 2880, function () {
|
||||
$xml = simplexml_load_string((new Client())->get($this->url, [
|
||||
'headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
|
||||
])->getBody()->getContents(), null, LIBXML_NOCDATA);
|
||||
return $this->cache->remember('feeds', 720, function () {
|
||||
try {
|
||||
$xml = simplexml_load_string((new Client())->get($this->url, [
|
||||
'headers' => ['Accept' => 'application/rss+xml', 'User-Agent' => defined('CACHET_VERSION') ? 'cachet/'.constant('CACHET_VERSION') : 'cachet'],
|
||||
])->getBody()->getContents(), null, LIBXML_NOCDATA);
|
||||
|
||||
return json_decode(json_encode($xml));
|
||||
return json_decode(json_encode($xml));
|
||||
} catch (Exception $e) {
|
||||
// Do nothing, this isn't critical.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@if($entries)
|
||||
<div class="col-sm-12 col-lg-6">
|
||||
<div class="stats-widget">
|
||||
<div class='stats-top'>
|
||||
@@ -94,12 +95,13 @@
|
||||
<div class='stats-body'>
|
||||
<div class="list-group">
|
||||
@foreach($entries as $entry)
|
||||
<a class="list-group-item" href="{{ $entry->link }}" target="_blank">{{ $entry->title }}, <small>{{ $entry->pubDate }}</small></a>
|
||||
<a class="list-group-item" href="{{ $entry->link }}" target="_blank">{{ $entry->title }}, <small>{{ $entry->pubDate }}</small> <span class="badge"><i class="ion-android-open"></i></span></a>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@if(Session::get('setup.done'))
|
||||
|
||||
Reference in New Issue
Block a user