diff --git a/Blacklight/Contents.php b/Blacklight/Contents.php index 70cd74f67..0715f352a 100755 --- a/Blacklight/Contents.php +++ b/Blacklight/Contents.php @@ -4,6 +4,7 @@ namespace Blacklight; use App\Models\User; use App\Models\Content; +use Illuminate\Support\Arr; /** * Class Contents. @@ -143,7 +144,7 @@ class Contents return false; } - return array_first($row); + return Arr::first($row); } /** diff --git a/Blacklight/Genres.php b/Blacklight/Genres.php index 7f8f68be3..2926e5840 100755 --- a/Blacklight/Genres.php +++ b/Blacklight/Genres.php @@ -4,6 +4,7 @@ namespace Blacklight; use App\Models\Genre; use App\Models\Category; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Cache; @@ -123,7 +124,7 @@ class Genres $sql = $this->getListQuery($type, $activeOnly); $sql .= ' LIMIT '.$num.' OFFSET '.$start; - return (array) array_first(DB::select($sql)); + return (array) Arr::first(DB::select($sql)); } /** diff --git a/Blacklight/Movie.php b/Blacklight/Movie.php index 6f3d73552..35dd6b5b1 100755 --- a/Blacklight/Movie.php +++ b/Blacklight/Movie.php @@ -2,6 +2,7 @@ namespace Blacklight; +use Illuminate\Support\Arr; use Imdb\Title; use Imdb\Config; use aharen\OMDbAPI; @@ -830,7 +831,7 @@ class Movie } else { $ret['rating'] = ''; } - $actors = array_pluck($tmdbLookup['credits']['cast'], 'name'); + $actors = Arr::pluck($tmdbLookup['credits']['cast'], 'name'); if (! empty($actors)) { $ret['actors'] = $actors; } else { @@ -907,7 +908,7 @@ class Movie $ret = [ 'title' => $result->orig_title(), 'tagline' => $result->tagline(), - 'plot' => array_get($result->plot_split(), '0.plot'), + 'plot' => Arr::get($result->plot_split(), '0.plot'), 'rating' => ! empty($result->rating()) ? $result->rating() : '', 'year' => $result->year(), 'cover' => $result->photo(), diff --git a/Blacklight/NameFixer.php b/Blacklight/NameFixer.php index 4f9bd1eed..867a5b59d 100755 --- a/Blacklight/NameFixer.php +++ b/Blacklight/NameFixer.php @@ -8,6 +8,7 @@ use App\Models\Release; use App\Models\Category; use Blacklight\utility\Utility; use Blacklight\processing\PostProcess; +use Illuminate\Support\Arr; /** * Class NameFixer. @@ -1027,7 +1028,7 @@ class NameFixer if ($status !== '') { foreach ($status as $key => $stat) { - $updateColumns = array_add($updateColumns, $key, $stat); + $updateColumns = Arr::add($updateColumns, $key, $stat); } } @@ -1169,7 +1170,7 @@ class NameFixer if (\strlen($preTitle) >= 15 && preg_match(self::PREDB_REGEX, $preTitle)) { $titlematch = $this->sphinx->searchIndexes('releases_rt', $preTitle, ['name', 'searchname', 'filename']); if (! empty($titlematch)) { - $join = implode(',', array_pluck($titlematch, 'id')); + $join = implode(',', Arr::pluck($titlematch, 'id')); } } diff --git a/Blacklight/Regexes.php b/Blacklight/Regexes.php index bde78d63f..2e6dfab8e 100755 --- a/Blacklight/Regexes.php +++ b/Blacklight/Regexes.php @@ -8,6 +8,7 @@ use App\Models\Category; use App\Models\CategoryRegex; use App\Models\CollectionRegex; use App\Models\ReleaseNamingRegex; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; /** @@ -109,7 +110,7 @@ class Regexes */ public function getRegexByID($id): array { - return (array) array_first(DB::select(sprintf('SELECT * FROM %s WHERE id = %d LIMIT 1', $this->tableName, $id))); + return (array) Arr::first(DB::select(sprintf('SELECT * FROM %s WHERE id = %d LIMIT 1', $this->tableName, $id))); } /** diff --git a/Blacklight/Releases.php b/Blacklight/Releases.php index f01f70ccb..5e9138b4c 100755 --- a/Blacklight/Releases.php +++ b/Blacklight/Releases.php @@ -8,6 +8,7 @@ use App\Models\Category; use App\Models\Settings; use Chumper\Zipper\Zipper; use Blacklight\utility\Utility; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\File; use Illuminate\Support\Facades\Cache; @@ -635,7 +636,7 @@ class Releases $results = $this->sphinxSearch->searchIndexes('releases_rt', '', [], $searchFields); - $searchResult = array_pluck($results, 'id'); + $searchResult = Arr::pluck($results, 'id'); $catQuery = ''; if ($type === 'basic') { @@ -731,7 +732,7 @@ class Releases public function apiSearch($searchName, $groupName, $offset = 0, $limit = 1000, $maxAge = -1, array $excludedCats = [], array $cat = [-1], $minSize = 0, array $tags = []) { if ($searchName !== -1) { - $searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $searchName, ['searchname']), 'id'); + $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $searchName, ['searchname']), 'id'); } $catQuery = Category::getCategorySearch($cat); @@ -871,7 +872,7 @@ class Releases } if (! empty($name)) { - $searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); } $whereSql = sprintf( @@ -1016,7 +1017,7 @@ class Releases } if (! empty($name)) { - $searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); } $whereSql = sprintf( @@ -1093,7 +1094,7 @@ class Releases public function animeSearch($aniDbID, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, array $excludedCategories = []) { if (! empty($name)) { - $searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); } $whereSql = sprintf( @@ -1167,7 +1168,7 @@ class Releases public function moviesSearch($imDbId = -1, $tmDbId = -1, $traktId = -1, $offset = 0, $limit = 100, $name = '', array $cat = [-1], $maxAge = -1, $minSize = 0, array $excludedCategories = [], array $tags = []) { if (! empty($name)) { - $searchResult = array_pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); + $searchResult = Arr::pluck($this->sphinxSearch->searchIndexes('releases_rt', $name, ['searchname']), 'id'); } $whereSql = sprintf( diff --git a/Blacklight/TmuxRun.php b/Blacklight/TmuxRun.php index afacd6106..d9a18bfaf 100755 --- a/Blacklight/TmuxRun.php +++ b/Blacklight/TmuxRun.php @@ -3,6 +3,7 @@ namespace Blacklight; use App\Models\Settings; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; /** @@ -770,7 +771,7 @@ class TmuxRun extends Tmux */ protected function _runSharing($pane, &$runVar): void { - $sharing = (array) array_first(DB::select('SELECT enabled, posting, fetching FROM sharing')); + $sharing = (array) Arr::first(DB::select('SELECT enabled, posting, fetching FROM sharing')); if (! empty($sharing) && (int) $sharing['enabled'] === 1 && (int) $runVar['settings']['run_sharing'] === 1 && ((int) $sharing['posting'] === 1 || (int) $sharing['fetching'] === 1) && shell_exec("tmux list-panes -t{$runVar['constants']['tmux_session']}:${pane} | grep ^0 | grep -c dead") == 1) { shell_exec( diff --git a/Changelog b/Changelog index 953801ec4..50b03ca9e 100755 --- a/Changelog +++ b/Changelog @@ -1,4 +1,5 @@ 2019-01-29 DariusIII + * Chg: Replace usage of array_ helper with Arr class directly to prepare for Laravel 5.8 changes * Chg: Replace usage of str_ helper with Str class directly to prepare for Laravel 5.8 changes * Chg: Update vlucas/phpdotenv to version 2.6.1 * Chg: Update used libraries to their latest versions diff --git a/app/Http/Controllers/AdultController.php b/app/Http/Controllers/AdultController.php index 56646ff2e..f682a6693 100644 --- a/app/Http/Controllers/AdultController.php +++ b/app/Http/Controllers/AdultController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Blacklight\XXX; use App\Models\Category; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class AdultController extends BasePageController { @@ -29,7 +30,7 @@ class AdultController extends BasePageController ]; } $category = Category::XXX_ROOT; - if ($id && \in_array($id, array_pluck($mtmp, 'title'), false)) { + if ($id && \in_array($id, Arr::pluck($mtmp, 'title'), false)) { $cat = Category::query() ->where('title', $id) ->where('parentid', '=', Category::XXX_ROOT) diff --git a/app/Http/Controllers/Auth/LoginController.php b/app/Http/Controllers/Auth/LoginController.php index e0f9b7291..c52f96919 100644 --- a/app/Http/Controllers/Auth/LoginController.php +++ b/app/Http/Controllers/Auth/LoginController.php @@ -6,6 +6,7 @@ use App\Models\User; use App\Models\Settings; use Illuminate\Http\Request; use App\Http\Controllers\Controller; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Validator; use Illuminate\Foundation\Auth\AuthenticatesUsers; @@ -94,7 +95,7 @@ class LoginController extends Controller return $this->showLoginForm($error); } - $error = implode('', array_collapse($validator->errors()->toArray())); + $error = implode('', Arr::collapse($validator->errors()->toArray())); return $this->showLoginForm($error); } diff --git a/app/Http/Controllers/Auth/RegisterController.php b/app/Http/Controllers/Auth/RegisterController.php index b24d8bf11..9a76737be 100644 --- a/app/Http/Controllers/Auth/RegisterController.php +++ b/app/Http/Controllers/Auth/RegisterController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Auth; use App\Models\User; use App\Models\Settings; use App\Models\Invitation; +use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Http\Request; use Blacklight\utility\Utility; @@ -101,7 +102,7 @@ class RegisterController extends Controller } if ($validator->fails()) { - $error = implode('', array_collapse($validator->errors()->toArray())); + $error = implode('', Arr::collapse($validator->errors()->toArray())); return $this->showRegistrationForm($error); } diff --git a/app/Http/Controllers/BasePageController.php b/app/Http/Controllers/BasePageController.php index 74c8a65d2..85e3763b0 100644 --- a/app/Http/Controllers/BasePageController.php +++ b/app/Http/Controllers/BasePageController.php @@ -10,6 +10,7 @@ use App\Models\Category; use App\Models\Settings; use Blacklight\Contents; use App\Models\Forumpost; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Auth; use Illuminate\Pagination\LengthAwarePaginator; @@ -86,7 +87,7 @@ class BasePageController extends Controller $this->settings = new Settings(); $this->smarty = app('smarty.view'); - foreach (array_get(config('ytake-laravel-smarty'), 'plugins_paths', []) as $plugins) { + foreach (Arr::get(config('ytake-laravel-smarty'), 'plugins_paths', []) as $plugins) { $this->smarty->addPluginsDir($plugins); } $this->smarty->error_reporting = E_ALL & ~E_NOTICE; diff --git a/app/Http/Controllers/BooksController.php b/app/Http/Controllers/BooksController.php index d14c40d2e..88711264c 100644 --- a/app/Http/Controllers/BooksController.php +++ b/app/Http/Controllers/BooksController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Blacklight\Books; use App\Models\Category; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class BooksController extends BasePageController { @@ -31,7 +32,7 @@ class BooksController extends BasePageController ]; } $category = Category::BOOKS_ROOT; - if ($id && \in_array($id, array_pluck($btmp, 'title'), false)) { + if ($id && \in_array($id, Arr::pluck($btmp, 'title'), false)) { $cat = Category::query() ->where('title', $id) ->where('parentid', '=', Category::BOOKS_ROOT) diff --git a/app/Http/Controllers/ConsoleController.php b/app/Http/Controllers/ConsoleController.php index 7efc520e9..8bf6d7ea2 100644 --- a/app/Http/Controllers/ConsoleController.php +++ b/app/Http/Controllers/ConsoleController.php @@ -6,6 +6,7 @@ use Blacklight\Genres; use Blacklight\Console; use App\Models\Category; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class ConsoleController extends BasePageController { @@ -35,7 +36,7 @@ class ConsoleController extends BasePageController ]; } $category = Category::GAME_ROOT; - if ($id && \in_array($id, array_pluck($ctmp, 'title'), false)) { + if ($id && \in_array($id, Arr::pluck($ctmp, 'title'), false)) { $cat = Category::query() ->where('title', $id) ->where('parentid', '=', Category::GAME_ROOT) diff --git a/app/Http/Controllers/MovieController.php b/app/Http/Controllers/MovieController.php index bb7ed5bea..269b70b63 100644 --- a/app/Http/Controllers/MovieController.php +++ b/app/Http/Controllers/MovieController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers; use Blacklight\Movie; use App\Models\Category; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class MovieController extends BasePageController { @@ -71,7 +72,7 @@ class MovieController extends BasePageController } $category = $request->has('imdb') ? -1 : Category::MOVIE_ROOT; - if ($id && \in_array($id, array_pluck($mtmp, 'title'), false)) { + if ($id && \in_array($id, Arr::pluck($mtmp, 'title'), false)) { $cat = Category::query() ->where(['title'=> $id, 'parentid' => Category::MOVIE_ROOT]) ->first(['id']); diff --git a/app/Http/Controllers/MusicController.php b/app/Http/Controllers/MusicController.php index 0da63978a..3b99ebf41 100644 --- a/app/Http/Controllers/MusicController.php +++ b/app/Http/Controllers/MusicController.php @@ -6,6 +6,7 @@ use Blacklight\Music; use Blacklight\Genres; use App\Models\Category; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class MusicController extends BasePageController { @@ -32,7 +33,7 @@ class MusicController extends BasePageController } $category = Category::MUSIC_ROOT; - if ($id && \in_array($id, array_pluck($mtmp, 'title'), false)) { + if ($id && \in_array($id, Arr::pluck($mtmp, 'title'), false)) { $cat = Category::query() ->where('title', $id) ->where('parentid', '=', Category::MUSIC_ROOT) diff --git a/app/Http/Controllers/ProfileController.php b/app/Http/Controllers/ProfileController.php index d348a507a..bca69253a 100644 --- a/app/Http/Controllers/ProfileController.php +++ b/app/Http/Controllers/ProfileController.php @@ -13,6 +13,7 @@ use Illuminate\Http\Request; use App\Models\ReleaseComment; use Blacklight\utility\Utility; use App\Jobs\SendAccountDeletedEmail; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\Validator; use Illuminate\Support\Str; use Jrean\UserVerification\Facades\UserVerification; @@ -159,7 +160,7 @@ class ProfileController extends BasePageController ]); if ($validator->fails()) { - $errorStr = implode('', array_collapse($validator->errors()->toArray())); + $errorStr = implode('', Arr::collapse($validator->errors()->toArray())); } elseif (! empty($request->input('nzbgeturl')) && $nzbGet->verifyURL($request->input('nzbgeturl')) === false) { $errorStr = 'The NZBGet URL you entered is invalid!'; } elseif ((! $request->has('saburl') && $request->has('sabapikey')) || ($request->has('saburl') && ! $request->has('sabapikey'))) { diff --git a/app/Http/Controllers/SeriesController.php b/app/Http/Controllers/SeriesController.php index a1fdc4ed9..de479096b 100644 --- a/app/Http/Controllers/SeriesController.php +++ b/app/Http/Controllers/SeriesController.php @@ -6,6 +6,7 @@ use App\Models\Video; use Blacklight\Releases; use App\Models\UserSerie; use Illuminate\Http\Request; +use Illuminate\Support\Arr; class SeriesController extends BasePageController { @@ -61,7 +62,7 @@ class SeriesController extends BasePageController $series[$r->series][$r->episode][] = $r; } - $this->smarty->assign('seasons', array_sort_recursive($series)); + $this->smarty->assign('seasons', Arr::sortRecursive($series)); $this->smarty->assign('show', $show); $this->smarty->assign('myshows', $myshows); diff --git a/app/Models/Predb.php b/app/Models/Predb.php index db4a79e87..5f0449480 100644 --- a/app/Models/Predb.php +++ b/app/Models/Predb.php @@ -5,6 +5,7 @@ namespace App\Models; use Blacklight\ColorCLI; use Blacklight\ConsoleTools; use Blacklight\SphinxSearch; +use Illuminate\Support\Arr; use Laravel\Scout\Searchable; use Watson\Rememberable\Rememberable; use Illuminate\Database\Eloquent\Model; @@ -183,7 +184,7 @@ class Predb extends Model $sql = self::query()->remember(config('nntmux.cache_expiry_medium'))->leftJoin('releases', 'releases.predb_id', '=', 'predb.id')->orderByDesc('predb.predate'); if (! empty($search)) { $sphinx = new SphinxSearch(); - $ids = array_pluck($sphinx->searchIndexes('predb_rt', $search, ['title']), 'id'); + $ids = Arr::pluck($sphinx->searchIndexes('predb_rt', $search, ['title']), 'id'); $sql->whereIn('predb.id', $ids); } diff --git a/app/Models/User.php b/app/Models/User.php index b0871f5d4..91d8fa830 100644 --- a/app/Models/User.php +++ b/app/Models/User.php @@ -3,6 +3,7 @@ namespace App\Models; use Blacklight\ColorCLI; +use Illuminate\Support\Arr; use Illuminate\Support\Str; use Illuminate\Http\Request; use App\Jobs\SendInviteEmail; @@ -690,7 +691,7 @@ class User extends Authenticatable ]); if ($validator->fails()) { - (new ColorCLI())->error(implode('', array_collapse($validator->errors()->toArray()))); + (new ColorCLI())->error(implode('', Arr::collapse($validator->errors()->toArray()))); } // Make sure this is the last check, as if a further validation check failed, the invite would still have been used up. diff --git a/misc/sphinxsearch/populate_rt_indexes.php b/misc/sphinxsearch/populate_rt_indexes.php index 4c0ca352d..c13a30955 100644 --- a/misc/sphinxsearch/populate_rt_indexes.php +++ b/misc/sphinxsearch/populate_rt_indexes.php @@ -5,6 +5,7 @@ require_once dirname(__DIR__, 2).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; use App\Models\Predb; use App\Models\Release; use Blacklight\SphinxSearch; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; if (! isset($argv[1])) { @@ -26,7 +27,7 @@ function populate_rt($table, $max) $allowedIndexes = ['releases_rt', 'predb_rt']; if (\in_array($table, $allowedIndexes, true)) { $sphinx = new SphinxSearch(); - $sphinx->truncateRTIndex(array_wrap($table)); + $sphinx->truncateRTIndex(Arr::wrap($table)); if ($table === 'releases_rt') { DB::statement('SET SESSION group_concat_max_len=16384;'); $query = 'SELECT r.id, r.name, r.searchname, r.fromname, IFNULL(GROUP_CONCAT(rf.name SEPARATOR " "),"") filename diff --git a/misc/update/tmux/bin/update_groups.php b/misc/update/tmux/bin/update_groups.php index fbbca0703..e7e6fd77f 100644 --- a/misc/update/tmux/bin/update_groups.php +++ b/misc/update/tmux/bin/update_groups.php @@ -7,6 +7,7 @@ use App\Models\Group; use Blacklight\ColorCLI; use App\Models\ShortGroup; use Blacklight\ConsoleTools; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; $start = now(); @@ -32,7 +33,7 @@ $colorCli->header('Inserting new values into short_groups table.'); DB::statement('TRUNCATE TABLE short_groups'); // Put into an array all active groups -$result = array_pluck(Group::query()->where('active', '=', 1)->orWhere('backfill', '=', 1)->get(['name']), 'name'); +$result = Arr::pluck(Group::query()->where('active', '=', 1)->orWhere('backfill', '=', 1)->get(['name']), 'name'); foreach ($data as $newgroup) { if (\in_array($newgroup['group'], $result, false)) { diff --git a/misc/update/tmux/monitor.php b/misc/update/tmux/monitor.php index cd09f7d4c..a0af497e0 100644 --- a/misc/update/tmux/monitor.php +++ b/misc/update/tmux/monitor.php @@ -9,6 +9,7 @@ use App\Models\Category; use App\Models\Settings; use Blacklight\ColorCLI; use Blacklight\TmuxOutput; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\DB; $pdo = DB::connection()->getPdo(); @@ -33,7 +34,7 @@ $db_name = config('nntmux.db_name'); $tmux_niceness = Settings::settingValue('site.tmux.niceness') ?? 2; -$runVar['constants'] = (array) array_first(DB::select($tRun->getConstantSettings())); +$runVar['constants'] = (array) Arr::first(DB::select($tRun->getConstantSettings())); //assign shell commands $runVar['commands']['_php'] = " nice -n{$tmux_niceness} php"; @@ -73,7 +74,7 @@ $psTableRowCount = $pdo->prepare($tblCount); while ($runVar['counts']['iterations'] > 0) { $timer01 = time(); // These queries are very fast, run every loop -- tmux and site settings - $runVar['settings'] = (array) array_first(DB::select($tRun->getMonitorSettings())); + $runVar['settings'] = (array) Arr::first(DB::select($tRun->getMonitorSettings())); $runVar['timers']['query']['tmux_time'] = (time() - $timer01); $runVar['settings']['book_reqids'] = (! empty($runVar['settings']['book_reqids']) @@ -131,8 +132,8 @@ while ($runVar['counts']['iterations'] > 0) { echo $e; } - $splitres = (array) array_first(DB::select($splitqry)); - $runVar['timers']['newOld'] = (array) array_first(DB::select($newOldqry)); + $splitres = (array) Arr::first(DB::select($splitqry)); + $runVar['timers']['newOld'] = (array) Arr::first(DB::select($newOldqry)); //assign split query results to main var if (is_array($splitres)) { @@ -173,7 +174,7 @@ while ($runVar['counts']['iterations'] > 0) { } catch (Exception $e) { echo $e; } - $proc1res = (array) array_first(DB::select($proc1qry)); + $proc1res = (array) Arr::first(DB::select($proc1qry)); $runVar['timers']['query']['proc1_time'] = (time() - $timer04); $runVar['timers']['query']['proc11_time'] = (time() - $timer01); @@ -183,7 +184,7 @@ while ($runVar['counts']['iterations'] > 0) { } catch (Exception $e) { echo $e; } - $proc2res = (array) array_first(DB::select($proc2qry)); + $proc2res = (array) Arr::first(DB::select($proc2qry)); $runVar['timers']['query']['proc2_time'] = (time() - $timer05); $runVar['timers']['query']['proc21_time'] = (time() - $timer01);