From d138a4f790a173887c6861441bf32d93a96bcc84 Mon Sep 17 00:00:00 2001 From: DariusIII Date: Thu, 15 Mar 2018 11:48:57 +0100 Subject: [PATCH] Fix sopme issues in Movie class, pointed out by scrutinizer --- Blacklight/Movie.php | 28 ++++++++++++---------------- Changelog | 1 + 2 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 76137f1e0..1b74f35a1 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -220,15 +220,15 @@ class Movie /** * Get movie releases with covers for movie browse page. * + * * @param $cat * @param $start * @param $num * @param $orderBy - * @param $maxAge + * @param int $maxAge * @param array $excludedCats * - * @return array|bool|\PDOStatement - * @throws \Exception + * @return array|bool */ public function getMovieRange($cat, $start, $num, $orderBy, $maxAge = -1, array $excludedCats = []) { @@ -276,7 +276,7 @@ class Movie Cache::put(md5($moviesSql), $movies, $expiresAt); } - $movieIDs = $releaseIDs = false; + $movieIDs = $releaseIDs = []; if (\is_array($movies['result'])) { foreach ($movies['result'] as $movie => $id) { @@ -410,17 +410,13 @@ class Movie */ public function getTrailer($imdbID) { - if (! is_numeric($imdbID)) { - return false; - } - $trailer = MovieInfo::query()->where('imdbid', $imdbID)->where('trailer', '!=', '')->first(['trailer']); if ($trailer !== null) { return $trailer['trailer']; } $data = $this->traktTv->client->movieSummary('tt'.$imdbID, 'full'); - if ($data) { + if ($data !== false) { $this->parseTraktTv($data); if (! empty($data['trailer'])) { return $data['trailer']; @@ -470,7 +466,7 @@ class Movie 'imdbid' => $this->checkTraktValue($imdbid), 'language' => $this->checkTraktValue($data['language']), 'plot' => $this->checkTraktValue($data['overview']), - 'rating' => round($this->checkTraktValue($data['rating']), 1), + 'rating' => $this->checkTraktValue($data['rating']), 'tagline' => $this->checkTraktValue($data['tagline']), 'title' => $this->checkTraktValue($data['title']), 'tmdbid' => $this->checkTraktValue($data['ids']['tmdb']), @@ -620,7 +616,7 @@ class Movie $mov = []; - $mov['cover'] = $mov['backdrop'] = $mov['banner'] = $movieID = 0; + $mov['cover'] = $mov['backdrop'] = $mov['banner'] = 0; $mov['type'] = $mov['director'] = $mov['actors'] = $mov['language'] = ''; $mov['imdbid'] = $imdbId; @@ -714,7 +710,7 @@ class Movie if ($this->echooutput && $this->service !== '') { ColorCLI::doEcho( - ColorCLI::headerOver(($movieID !== 0 ? 'Added/updated movie: ' : 'Nothing to update for movie: ')). + ColorCLI::headerOver( 'Added/updated movie: '). ColorCLI::primary( $mov['title']. ' ('. @@ -725,7 +721,7 @@ class Movie ); } - return $movieID !== 0; + return (int) $movieID > 0; } /** @@ -1100,7 +1096,7 @@ class Movie $this->currentRelID = $arr['id']; $movieName = $this->currentTitle; - if ($this->currentYear !== false) { + if ($this->currentYear !== '') { $movieName .= ' ('.$this->currentYear.')'; } @@ -1199,7 +1195,7 @@ class Movie $check = MovieInfo::query() ->where('title', 'LIKE', '%'.$this->currentTitle.'%'); - if ($this->currentYear !== false) { + if ($this->currentYear !== '') { $start = Carbon::parse($this->currentYear)->subYears(2)->year; $end = Carbon::parse($this->currentYear)->addYears(2)->year; $check->whereBetween('year', [$start, $end]); @@ -1249,7 +1245,7 @@ class Movie // Check if the name is long enough and not just numbers. if (\strlen($name) > 4 && ! preg_match('/^\d+$/', $name)) { $this->currentTitle = $name; - $this->currentYear = ($year === '' ? false : $year); + $this->currentYear = $year; return true; } diff --git a/Changelog b/Changelog index 41ef0cf2a..5bd2625ed 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-03-15 DariusIII + * Chg: Update Movie class, fix some of the issues pointed out by scrutinizer * Chg: Add back js defining variables to themes * Fix: Revert admin pages to old links/scripts format, fix category-list page 2018-03-14 DariusIII