🐛 Update checker now fails silently when Github.com is down #82

This commit is contained in:
MarceauKa 2020-09-08 15:44:16 +02:00
parent 8bc8183670
commit e8148e1938
2 changed files with 24 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace App\Services;
use App\Services\Shaark\Shaark;
use GuzzleHttp\Client;
use Illuminate\Support\Carbon;
class UpdateChecker
@ -14,10 +15,28 @@ class UpdateChecker
private function __construct()
{
$body = null;
try {
$feed = simplexml_load_file(self::FEED_URL);
$response = (new Client())->request('GET', self::FEED_URL, [
'headers' => [
'User-Agent' => 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.106 Safari/537.36',
],
'http_errors' => false,
'timeout' => 5,
]);
$body = $response->getBody()->getContents();
} catch (\Exception $e) {
unset($e);
return;
}
try {
$feed = simplexml_load_string($body);
} catch (\Exception $e) {
unset($e);
return;
}
if ($feed instanceof \SimpleXMLElement) {

View File

@ -4,6 +4,10 @@
- Health checks for links (thanks to [wyred](https://github.com/wyred), [#79](https://github.com/MarceauKa/shaark/pull/79))
## Fixed
- Update checker now fails silently when Github.com is down ([#82](https://github.com/MarceauKa/shaark/issues/82))
## Changed
- Dependencies update