Replace usage of array_ helper with Arr class directly to prepare for Laravel 5.8 changes

This commit is contained in:
DariusIII
2019-01-29 13:52:01 +01:00
parent 4b4de3acef
commit 08b8edbe2d
23 changed files with 57 additions and 34 deletions
+2 -1
View File
@@ -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);
}
/**
+2 -1
View File
@@ -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));
}
/**
+3 -2
View File
@@ -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(),
+3 -2
View File
@@ -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'));
}
}
+2 -1
View File
@@ -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)));
}
/**
+7 -6
View File
@@ -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(
+2 -1
View File
@@ -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(
+1
View File
@@ -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
+2 -1
View File
@@ -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)
@@ -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);
}
@@ -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);
}
+2 -1
View File
@@ -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;
+2 -1
View File
@@ -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)
+2 -1
View File
@@ -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)
+2 -1
View File
@@ -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']);
+2 -1
View File
@@ -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)
+2 -1
View File
@@ -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'))) {
+2 -1
View File
@@ -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);
+2 -1
View File
@@ -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);
}
+2 -1
View File
@@ -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.
+2 -1
View File
@@ -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
+2 -1
View File
@@ -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)) {
+7 -6
View File
@@ -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);