Handle failing to fetch blog posts. Fixes #1878
This commit is contained in:
@@ -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.
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user