From 49de43355b15a73f0457d99d06c5ddcae529adce Mon Sep 17 00:00:00 2001 From: DariusIII Date: Mon, 6 Mar 2017 14:16:52 +0100 Subject: [PATCH] Fix wrong usage of null coalescing operator --- Changelog | 1 + misc/update/nix/tmux/monitor.php | 2 +- nntmux/Books.php | 2 +- nntmux/Console.php | 2 +- nntmux/Movie.php | 2 +- nntmux/Music.php | 28 ++++++++++++++-------------- nntmux/processing/tv/TMDB.php | 4 ++-- www/pages/forgottenpassword.php | 4 ++-- 8 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Changelog b/Changelog index c3d7dfcc7..c91fe6e0c 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2017-03-06 DariusIII + * Fix: Fix wrong usage of null coalescing operator * Chg: Remove unused classes (Desura, Greenlight), update Logger, Logging, Menu, MiscSorter classes 2017-03-03 DariusIII * Chg: Update ternary to PHP 7 style in start.php diff --git a/misc/update/nix/tmux/monitor.php b/misc/update/nix/tmux/monitor.php index b775c2698..81cf34c8d 100644 --- a/misc/update/nix/tmux/monitor.php +++ b/misc/update/nix/tmux/monitor.php @@ -22,7 +22,7 @@ $db_name = DB_NAME; $dbtype = DB_SYSTEM; $tmux = $tRun->get('niceness'); -$tmux_niceness = isset($tmux->niceness) ?? 2; +$tmux_niceness = $tmux->niceness ?? 2; $runVar['constants'] = $pdo->queryOneRow($tRun->getConstantSettings()); diff --git a/nntmux/Books.php b/nntmux/Books.php index c36330a7a..1acbc9164 100755 --- a/nntmux/Books.php +++ b/nntmux/Books.php @@ -259,7 +259,7 @@ class Books ); $return = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); if (!empty($return)) { - $return[0]['_totalcount'] = (isset($books['total']) ?? 0); + $return[0]['_totalcount'] = $books['total'] ?? 0; } return $return; } diff --git a/nntmux/Console.php b/nntmux/Console.php index 859c6c71a..1297870eb 100755 --- a/nntmux/Console.php +++ b/nntmux/Console.php @@ -253,7 +253,7 @@ class Console ), true, NN_CACHE_EXPIRY_MEDIUM ); if (!empty($return)) { - $return[0]['_totalcount'] = (isset($consoles['total']) ?? 0); + $return[0]['_totalcount'] = $consoles['total'] ?? 0; } return $return; } diff --git a/nntmux/Movie.php b/nntmux/Movie.php index a25c1c3ac..25686eecd 100755 --- a/nntmux/Movie.php +++ b/nntmux/Movie.php @@ -359,7 +359,7 @@ class Movie ); $return = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); if (!empty($return)) { - $return[0]['_totalcount'] = (isset($movies['total']) ?? 0); + $return[0]['_totalcount'] = $movies['total'] ?? 0; } return $return; } diff --git a/nntmux/Music.php b/nntmux/Music.php index 7e2af868f..439eafffb 100755 --- a/nntmux/Music.php +++ b/nntmux/Music.php @@ -83,8 +83,8 @@ class Music $this->pubkey = Settings::value('APIs..amazonpubkey'); $this->privkey = Settings::value('APIs..amazonprivkey'); $this->asstag = Settings::value('APIs..amazonassociatetag'); - $this->musicqty = (Settings::value('..maxmusicprocessed') != '') ? Settings::value('..maxmusicprocessed') : 150; - $this->sleeptime = (Settings::value('..amazonsleep') != '') ? Settings::value('..amazonsleep') : 1000; + $this->musicqty = Settings::value('..maxmusicprocessed') != '' ? Settings::value('..maxmusicprocessed') : 150; + $this->sleeptime = Settings::value('..amazonsleep') != '' ? Settings::value('..amazonsleep') : 1000; $this->imgSavePath = NN_COVERS . 'music' . DS; $this->renamed = ''; if (Settings::value('..lookupmusic') == 2) { @@ -101,7 +101,7 @@ class Music */ public function getMusicInfo($id) { - return $this->pdo->queryOneRow(sprintf("SELECT musicinfo.*, genres.title AS genres FROM musicinfo LEFT OUTER JOIN genres ON genres.id = musicinfo.genres_id WHERE musicinfo.id = %d ", $id)); + return $this->pdo->queryOneRow(sprintf('SELECT musicinfo.*, genres.title AS genres FROM musicinfo LEFT OUTER JOIN genres ON genres.id = musicinfo.genres_id WHERE musicinfo.id = %d ', $id)); } /** @@ -114,7 +114,7 @@ class Music { $pdo = $this->pdo; $like = 'ILIKE'; - if ($pdo->dbSystem() === 'mysql') { + if ($pdo->DbSystem() === 'mysql') { $like = 'LIKE'; } @@ -139,9 +139,9 @@ class Music } } $searchwords = trim($searchwords); - $searchsql .= sprintf(" MATCH(artist, title) AGAINST(%s IN BOOLEAN MODE)", $pdo->escapeString($searchwords)); + $searchsql .= sprintf(' MATCH(artist, title) AGAINST(%s IN BOOLEAN MODE)', $pdo->escapeString($searchwords)); } - return $pdo->queryOneRow(sprintf("SELECT * FROM musicinfo WHERE %s", $searchsql)); + return $pdo->queryOneRow(sprintf('SELECT * FROM musicinfo WHERE %s', $searchsql)); } /** @@ -155,12 +155,12 @@ class Music if ($start === false) { - $limit = ""; + $limit = ''; } else { - $limit = " LIMIT " . $num . " OFFSET " . $start; + $limit = ' LIMIT ' . $num . ' OFFSET ' . $start; } - return $this->pdo->query(" SELECT * FROM musicinfo ORDER BY createddate DESC" . $limit); + return $this->pdo->query('SELECT * FROM musicinfo ORDER BY createddate DESC' . $limit); } /** @@ -169,8 +169,8 @@ class Music public function getCount() { - $res = $this->pdo->queryOneRow("SELECT COUNT(id) AS num FROM musicinfo"); - return $res["num"]; + $res = $this->pdo->queryOneRow('SELECT COUNT(id) AS num FROM musicinfo'); + return $res['num']; } /** @@ -191,9 +191,9 @@ class Music $catsrch = (new Category(['Settings' => $this->pdo]))->getCategorySearch($cat); } - $exccatlist = ""; + $exccatlist = ''; if (count($excludedcats) > 0) { - $exccatlist = " AND r.categories_id NOT IN (" . implode(",", $excludedcats) . ")"; + $exccatlist = ' AND r.categories_id NOT IN (' . implode(',', $excludedcats) . ')'; } $order = $this->getMusicOrder($orderby); @@ -269,7 +269,7 @@ class Music ); $return = $this->pdo->query($sql, true, NN_CACHE_EXPIRY_MEDIUM); if (!empty($return)) { - $return[0]['_totalcount'] = (isset($music['total']) ? $music['total'] : 0); + $return[0]['_totalcount'] = $music['total'] ?? 0; } return $return; diff --git a/nntmux/processing/tv/TMDB.php b/nntmux/processing/tv/TMDB.php index c5631eaab..c108e13ae 100755 --- a/nntmux/processing/tv/TMDB.php +++ b/nntmux/processing/tv/TMDB.php @@ -292,7 +292,7 @@ class TMDB extends TV foreach ($showAlternativeTitles['alternative_titles']['results'] AS $aka) { $highest['alternative_titles'][] = $aka['title']; } - $highest['network'] = (isset($show['networks'][0]['name']) ?? ''); + $highest['network'] = $show['networks'][0]['name'] ?? ''; $highest['external_ids'] = $showExternalIds['external_ids']; } $return = $this->formatShowInfo($highest); @@ -375,7 +375,7 @@ class TMDB extends TV 'summary' => (string)$show['overview'], 'started' => (string)$show['first_air_date'], 'publisher' => isset($show['network']) ? (string)$show['network'] : '', - 'country' => (string)(isset($show['origin_country'][0]) ?? ''), + 'country' => (string)$show['origin_country'][0] ?? '', 'source' => (int)parent::SOURCE_TMDB, 'imdb' => isset($imdb['imdbid']) ? (int)$imdb['imdbid'] : 0, 'tvdb' => isset($show['external_ids']['tvdb_id']) ? (int)$show['external_ids']['tvdb_id'] : 0, diff --git a/www/pages/forgottenpassword.php b/www/pages/forgottenpassword.php index 52ce0c3a4..7bd916786 100644 --- a/www/pages/forgottenpassword.php +++ b/www/pages/forgottenpassword.php @@ -8,7 +8,7 @@ if ($page->users->isLoggedIn()) { header('Location: ' . WWW_TOP . '/'); } -$action = isset($_REQUEST['action']) ?? 'view'; +$action = $_REQUEST['action'] ?? 'view'; $captcha = new Captcha($page); $email = $sent = $confirmed = ''; @@ -46,7 +46,7 @@ switch($action) { case 'submit': if ($captcha->getError() === false) { - $email = !empty($_POST['email']) ?? ''; + $email = $_POST['email'] ?? ''; if (empty($email)) { $page->smarty->assign('error', 'Missing Email'); } else {