diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index fe9bf83bc..3e4abb99d 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -184,12 +184,12 @@ class Movie $this->pdo = ($options['Settings'] instanceof DB ? $options['Settings'] : new DB()); $this->releaseImage = ($options['ReleaseImage'] instanceof ReleaseImage ? $options['ReleaseImage'] : new ReleaseImage()); - $this->traktcheck = Settings::settingValue('APIs..trakttvclientkey', true); + $this->traktcheck = Settings::settingValue('APIs..trakttvclientkey'); if ($this->traktcheck !== null) { $this->traktTv = new TraktTv(['Settings' => $this->pdo]); } $this->client = new Client(); - $this->tmdbtokencheck = Settings::settingValue('APIs..tmdbkey', true); + $this->tmdbtokencheck = Settings::settingValue('APIs..tmdbkey'); if ($this->tmdbtokencheck !== null) { $this->tmdbtoken = new ApiToken($this->tmdbtokencheck); $this->tmdbclient = new TmdbClient($this->tmdbtoken, [ @@ -201,11 +201,11 @@ class Movie $this->tmdbconfig = $this->configRepository->load(); $this->helper = new ImageHelper($this->tmdbconfig); } - $this->fanartapikey = Settings::settingValue('APIs..fanarttvkey', true); + $this->fanartapikey = Settings::settingValue('APIs..fanarttvkey'); if ($this->fanartapikey !== null) { $this->fanart = new FanartTV($this->fanartapikey); } - $this->omdbapikey = Settings::settingValue('APIs..omdbkey', true); + $this->omdbapikey = Settings::settingValue('APIs..omdbkey'); if ($this->omdbapikey !== null) { $this->omdbApi = new OMDbAPI($this->omdbapikey); } diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index c5ad173ae..9067e2bf5 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -185,7 +185,7 @@ class Releases */ public static function showPasswords($query = null, $builder = false) { - $setting = Settings::settingValue('..showpasswordedrelease', true); + $setting = Settings::settingValue('..showpasswordedrelease'); $setting = ($setting !== null && is_numeric($setting)) ? $setting : 10; switch ($setting) { case 0: // Hide releases with a password or a potential password (Hide unprocessed releases). diff --git a/Blacklight/Tmux.php b/Blacklight/Tmux.php index 0b069eb74..a43665f23 100755 --- a/Blacklight/Tmux.php +++ b/Blacklight/Tmux.php @@ -343,7 +343,7 @@ class Tmux */ public function rand_bool($loop, $chance = 60): bool { - $usecache = Settings::settingValue('site.tmux.usecache', true) ?? 0; + $usecache = Settings::settingValue('site.tmux.usecache') ?? 0; if ($loop === 1 || $usecache === 0) { return false; } diff --git a/Changelog b/Changelog index d0b50676f..c131a3c97 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2018-05-16 DariusIII + * Chg: settingValue function will not throw an exception anymore on empty setting value, but will return null * Chg: Check also tmdb, fanart and omdb keys * Chg: Add check for existence of trakttv api key in Movies class * Fix: Fix movies cover and full view diff --git a/app/Extensions/util/Versions.php b/app/Extensions/util/Versions.php index e9a3dd9d1..21cfd2456 100644 --- a/app/Extensions/util/Versions.php +++ b/app/Extensions/util/Versions.php @@ -248,7 +248,7 @@ class Versions extends Collection */ public function getSQLPatchFromDB(): ?string { - $dbVersion = Settings::settingValue('..sqlpatch', true); + $dbVersion = Settings::settingValue('..sqlpatch'); if (! is_numeric($dbVersion)) { throw new \RuntimeException('Bad sqlpatch value'); diff --git a/app/Models/Settings.php b/app/Models/Settings.php index 3a70427e9..7c67bca84 100644 --- a/app/Models/Settings.php +++ b/app/Models/Settings.php @@ -240,20 +240,11 @@ class Settings extends Model } /** - * Return the value of supplied setting. - * The setting can be either a normal condition array for the custom 'setting' finder or a - * dotted string notation setting. Note that dotted notation will be converted to an array, - * so it will be slower: Explicitly use the array format if speed it paramount. - * Be aware that this method only returns the first of any values found, so make sure your - * $setting produces a unique result. - * @param bool|array $setting - * @param bool $returnAlways Indicates if the method should throw an exception (false) or return - * null on failure. Defaults to throwing an exception. + * @param $setting * - * @return string|null The setting's value, or null on failure IF 'returnAlways' is true. - * @throws \Exception + * @return null|string */ - public static function settingValue($setting, $returnAlways = false): ?string + public static function settingValue($setting): ?string { $setting = self::settingToArray($setting); $result = self::query()->where([ @@ -264,8 +255,6 @@ class Settings extends Model if ($result !== null) { $value = $result; - } elseif ($returnAlways === false) { - throw new \RuntimeException('Unable to fetch setting from Db!'); } else { $value = null; } diff --git a/misc/update/tmux/run.php b/misc/update/tmux/run.php index fa3afff61..8f10b84a0 100644 --- a/misc/update/tmux/run.php +++ b/misc/update/tmux/run.php @@ -11,10 +11,10 @@ use Blacklight\utility\Utility; $pdo = new DB(); $DIR = NN_TMUX; $patch = Settings::settingValue('..sqlpatch'); -$import = Settings::settingValue('site.tmux.import', true) ?? 0; -$tmux_session = Settings::settingValue('site.tmux.tmux_session', true) ?? 0; -$seq = Settings::settingValue('site.tmux.sequential', true) ?? 0; -$powerline = Settings::settingValue('site.tmux.powerline', true) ?? 0; +$import = Settings::settingValue('site.tmux.import') ?? 0; +$tmux_session = Settings::settingValue('site.tmux.tmux_session') ?? 0; +$seq = Settings::settingValue('site.tmux.sequential') ?? 0; +$powerline = Settings::settingValue('site.tmux.powerline') ?? 0; $delaytimet = Settings::settingValue('..delaytime'); $delaytimet = $delaytimet ? (int) $delaytimet : 2;