mirror of
https://github.com/HDInnovations/UNIT3D-Community-Edition.git
synced 2026-05-02 16:29:49 -05:00
refactor: harden error handeling
This commit is contained in:
@@ -27,7 +27,7 @@ class EmailBlacklistUpdater
|
||||
$key = \config('email-blacklist.cache-key');
|
||||
$duration = Carbon::now()->addMonth();
|
||||
|
||||
$domains = \json_decode(\file_get_contents($url), true);
|
||||
$domains = \json_decode(\file_get_contents($url), true, 512, JSON_THROW_ON_ERROR);
|
||||
$count = \is_countable($domains) ? \count($domains) : 0;
|
||||
|
||||
// Retrieve blacklisted domains
|
||||
|
||||
@@ -39,7 +39,7 @@ class VersionController extends Controller
|
||||
public function checkVersion()
|
||||
{
|
||||
$client = new Client();
|
||||
$response = \json_decode($client->get('//api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody());
|
||||
$response = \json_decode($client->get('//api.github.com/repos/HDInnovations/UNIT3D/releases')->getBody(), true);
|
||||
$lastestVersion = $response[0]->tag_name;
|
||||
|
||||
return \response([
|
||||
|
||||
@@ -39,7 +39,7 @@ class Collection
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/collection/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -40,7 +40,7 @@ class Company
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/company/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
@@ -118,7 +118,7 @@ class Company
|
||||
$array = [];
|
||||
$this->page = 1;
|
||||
while ($data = $this->data['movies'][$this->page++]) {
|
||||
$json = json_decode($data, true); //01
|
||||
$json = json_decode($data, true, 512, JSON_THROW_ON_ERROR); //01
|
||||
foreach ($json['results'] as $row) {
|
||||
$array[] = $row;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ class Episode
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season.'/episode/'.$episode);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -38,7 +38,7 @@ class FindMovie
|
||||
|
||||
$response = $this->client->request('get', 'https://api.themoviedb.org/3/search/movie?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -38,7 +38,7 @@ class FindTv
|
||||
|
||||
$response = $this->client->request('get', 'https://api.themoviedb.org/3/search/tv?api_key='.config('api-keys.tmdb').'&query='.$query.'&first_air_date_year='.$year);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -38,7 +38,7 @@ class Genre
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/genre/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -39,7 +39,7 @@ class Movie
|
||||
|
||||
$response = $this->client->request('get', 'https://api.themoviedb.org/3/movie/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -39,7 +39,7 @@ class Network
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/network/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -39,7 +39,7 @@ class Person
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/person/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -39,7 +39,7 @@ class Season
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id.'/season/'.$season);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -39,7 +39,7 @@ class TV
|
||||
|
||||
$response = $this->client->request('get', 'https://api.TheMovieDB.org/3/tv/'.$id);
|
||||
|
||||
$this->data = json_decode($response->getBody()->getContents(), true);
|
||||
$this->data = json_decode($response->getBody()->getContents(), true, 512, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
public function index()
|
||||
|
||||
@@ -123,7 +123,7 @@ trait Auditable
|
||||
|
||||
$clean = \array_filter($data);
|
||||
|
||||
return \json_encode($clean);
|
||||
return \json_encode($clean, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -181,7 +181,7 @@ trait Auditable
|
||||
// Generate the JSON to store
|
||||
$data = self::generate('update', self::strip($model, $model->getOriginal()), self::strip($model, $model->getChanges()));
|
||||
|
||||
if (! \is_null($userId) && ! empty(\json_decode($data, true))) {
|
||||
if (! \is_null($userId) && ! empty(\json_decode($data, true, 512, JSON_THROW_ON_ERROR))) {
|
||||
// Store record
|
||||
$now = Carbon::now()->format('Y-m-d H:i:s');
|
||||
DB::table('audits')->insert([
|
||||
|
||||
Reference in New Issue
Block a user