From 2912c892020a46bc45ae39b942aa8c5221bf09fa Mon Sep 17 00:00:00 2001 From: xiaomlove Date: Mon, 18 Jul 2022 22:53:56 +0800 Subject: [PATCH] fix check redis version --- app/Console/Commands/Test.php | 13 +++++++++---- nexus/Database/NexusDB.php | 7 +++++-- nexus/Install/Install.php | 3 +-- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/app/Console/Commands/Test.php b/app/Console/Commands/Test.php index 506b1771..17570a6e 100644 --- a/app/Console/Commands/Test.php +++ b/app/Console/Commands/Test.php @@ -3,8 +3,9 @@ namespace App\Console\Commands; use App\Events\TorrentUpdated; +use App\Filament\Resources\System\AgentAllowResource; use App\Http\Resources\TagResource; -use App\Models\Ability; +use App\Models\AgentAllow; use App\Models\Attendance; use App\Models\Exam; use App\Models\ExamProgress; @@ -12,7 +13,6 @@ use App\Models\ExamUser; use App\Models\HitAndRun; use App\Models\Medal; use App\Models\Peer; -use App\Models\Role; use App\Models\SearchBox; use App\Models\Snatch; use App\Models\Tag; @@ -37,6 +37,7 @@ use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Hash; use Illuminate\Support\Facades\Redis; use Illuminate\Support\Facades\Storage; +use Illuminate\Support\Str; use JeroenG\Explorer\Domain\Syntax\Matching; use JeroenG\Explorer\Infrastructure\Scout\ElasticEngine; use League\Flysystem\StorageAttributes; @@ -46,7 +47,6 @@ use NexusPlugin\PostLike\PostLikeRepository; use NexusPlugin\StickyPromotion\Models\StickyPromotion; use NexusPlugin\StickyPromotion\Models\StickyPromotionParticipator; use Rhilip\Bencode\Bencode; -use Silber\Bouncer\Bouncer; class Test extends Command { @@ -81,7 +81,12 @@ class Test extends Command */ public function handle() { - Ability::initDefaults(); + $r = Str::of(class_basename(\App\Models\AgentAllow::class)) + ->plural() + ->kebab() + ->slug(); + + dd($r); } diff --git a/nexus/Database/NexusDB.php b/nexus/Database/NexusDB.php index 248631b1..83de1c5a 100644 --- a/nexus/Database/NexusDB.php +++ b/nexus/Database/NexusDB.php @@ -371,13 +371,16 @@ class NexusDB } } + /** + * @return mixed|\Redis|null + */ public static function redis() { if (IN_NEXUS) { global $Cache; - $Cache->getRedis(); + return $Cache->getRedis(); } else { - Redis::connection()->client(); + return Redis::connection()->client(); } } diff --git a/nexus/Install/Install.php b/nexus/Install/Install.php index df6cd8db..4ae9b193 100644 --- a/nexus/Install/Install.php +++ b/nexus/Install/Install.php @@ -665,8 +665,7 @@ class Install public function getRedisVersionInfo(): array { - global $Cache; - $redis = $Cache->getRedis(); + $redis = NexusDB::redis(); $result = $redis->info(); $version = $result['redis_version']; $match = version_compare($version, '2.0.0', '>=');