From 5a17c5d4c8d55bf9ca7985b82c424399a020d874 Mon Sep 17 00:00:00 2001 From: Shawn Rice Date: Tue, 1 Aug 2023 14:55:15 -0400 Subject: [PATCH] fix: Catch misnamed, undefined vars --- .../History/Listeners/LogSendingMessage.php | 4 +- app/Modules/History/Traits/Historable.php | 3 +- app/Modules/Queues/Models/Policy.php | 47 ------------------- app/Modules/Queues/Models/Qos.php | 39 +++++++++++++++ app/Modules/Queues/Models/Queue.php | 1 - .../Queues/Resources/lang/en/queues.php | 5 -- app/Modules/Resources/Console/CopyCommand.php | 2 +- app/Modules/Search/Models/Result.php | 20 ++++---- .../Controllers/Admin/StorageController.php | 16 ++++--- .../Http/Controllers/Api/UsageController.php | 7 ++- .../Storage/Listeners/GroupMembers.php | 4 +- 11 files changed, 71 insertions(+), 77 deletions(-) delete mode 100755 app/Modules/Queues/Models/Policy.php diff --git a/app/Modules/History/Listeners/LogSendingMessage.php b/app/Modules/History/Listeners/LogSendingMessage.php index 982c8ed8e..3902f3cd0 100644 --- a/app/Modules/History/Listeners/LogSendingMessage.php +++ b/app/Modules/History/Listeners/LogSendingMessage.php @@ -21,8 +21,8 @@ public function handle(MessageSending $event): void $headers = $event->message->getHeaders(); $classname = 'LogSendingMessage'; - $targetuserid = -2; - $targetobjectid = -2; + $targetuserid = 0; + $targetobjectid = 0; $objectid = ''; if ($headers->has('x-command')) diff --git a/app/Modules/History/Traits/Historable.php b/app/Modules/History/Traits/Historable.php index d9aa5bb63..5fba1ef4a 100755 --- a/app/Modules/History/Traits/Historable.php +++ b/app/Modules/History/Traits/Historable.php @@ -2,6 +2,7 @@ namespace App\Modules\History\Traits; +use Illuminate\Database\Eloquent\Relations\MorphMany; use Illuminate\Database\Eloquent\Model; use App\Modules\History\Models\History; @@ -70,7 +71,7 @@ public function writeHistory($action, array $old = [], array $new = []) /** * Model has history * - * @return object + * @return MorphMany */ public function history() { diff --git a/app/Modules/Queues/Models/Policy.php b/app/Modules/Queues/Models/Policy.php deleted file mode 100755 index d92ad9f37..000000000 --- a/app/Modules/Queues/Models/Policy.php +++ /dev/null @@ -1,47 +0,0 @@ - - */ - protected $guarded = [ - 'id' - ]; - - /** - * Defines a relationship to schedulers - * - * @return HasMany - */ - public function schedulers(): HasMany - { - return $this->hasMany(Queue::class, 'schedulerpolicyid'); - } -} diff --git a/app/Modules/Queues/Models/Qos.php b/app/Modules/Queues/Models/Qos.php index 7d15dffcc..e3ec8c47f 100755 --- a/app/Modules/Queues/Models/Qos.php +++ b/app/Modules/Queues/Models/Qos.php @@ -13,6 +13,45 @@ /** * Model for a queue Quality of Service + * + * @property int $scheduler_id + * @property string $name + * @property string $description + * @property string $flags + * @property int $grace_time + * @property int $max_jobs_pa + * @property int $max_jobs_per_user + * @property int $max_jobs_accrue_pa + * @property int $max_jobs_accrue_pu + * @property int $min_prio_thresh + * @property int $max_submit_jobs_pa + * @property int $max_submit_jobs_per_user + * @property string $max_tres_pa + * @property string $max_tres_pj + * @property string $max_tres_pn + * @property string $max_tres_pu + * @property string $max_tres_mins_pj + * @property string $max_tres_run_mins_pa + * @property string $max_tres_run_mins_pu + * @property string $min_tres_pj + * @property int $max_wall_duration_per_job + * @property int $grp_jobs + * @property int $grp_jobs_accrue + * @property int $grp_submit_jobs + * @property string $grp_tres + * @property string $grp_tres_mins + * @property string $grp_tres_run_mins + * @property int $grp_wall + * @property string $preempt + * @property int $preempt_mode + * @property int $preempt_exempt_time + * @property int $priority + * @property float $usage_factor + * @property float $usage_thres + * @property float $limit_factor + * @property Carbon|null $datetimecreated + * @property Carbon|null $datetimeremoved + * @property Carbon|null $datetimeedited */ class Qos extends Model { diff --git a/app/Modules/Queues/Models/Queue.php b/app/Modules/Queues/Models/Queue.php index a357a14ce..165a2a17d 100755 --- a/app/Modules/Queues/Models/Queue.php +++ b/app/Modules/Queues/Models/Queue.php @@ -1118,7 +1118,6 @@ public function addPurchase($sellerqueueid, $start, $stop = null, $nodecount = 0 /** * Delete entry and associated data * - * @param array $options * @return bool */ public function delete(): bool diff --git a/app/Modules/Queues/Resources/lang/en/queues.php b/app/Modules/Queues/Resources/lang/en/queues.php index 4cb26b356..9fc240290 100644 --- a/app/Modules/Queues/Resources/lang/en/queues.php +++ b/app/Modules/Queues/Resources/lang/en/queues.php @@ -84,7 +84,6 @@ 'acl users enabled desc' => 'User ACL Enabled', 'acl groups' => 'Group ACL', 'acl groups desc' => 'Comma separated list of ACL groups', - 'priority' => 'Priority', 'submission state' => 'Submission to the queue', 'gpus' => 'GPUs', 'nodes' => 'Nodes', @@ -102,12 +101,9 @@ 'lender' => 'Lender', 'org owned' => '(Organization Owned)', 'standby' => 'Standby', - 'owner' => 'Owner', 'work' => 'Workq', 'debug' => 'Debug', 'end of life' => 'end of cluster life', - 'nodes' => 'Nodes', - 'cores' => 'Cores', 'start' => 'Start', 'stop' => 'Stop', 'end' => 'End', @@ -165,7 +161,6 @@ // Qos 'limits' => 'Limits', 'description' => 'Description', - 'min_prio_thresh' => 'Minimum priority threshold', 'max_jobs_pa' => 'Max jobs per account', 'max_jobs_pa desc' => 'The maximum number of jobs an account (or subaccount) can have running at a given time.', 'max_jobs_per_user' => 'Max jobs per user', diff --git a/app/Modules/Resources/Console/CopyCommand.php b/app/Modules/Resources/Console/CopyCommand.php index f0b4bea76..422ca6587 100644 --- a/app/Modules/Resources/Console/CopyCommand.php +++ b/app/Modules/Resources/Console/CopyCommand.php @@ -41,7 +41,7 @@ public function handle(): int if (!$asset || !$asset->id) { - $this->danger('Failed to find resource entry for ID #' . $id); + $this->error('Failed to find resource entry for ID #' . $id); return Command::FAILURE; } diff --git a/app/Modules/Search/Models/Result.php b/app/Modules/Search/Models/Result.php index 1304f16c4..35f954643 100644 --- a/app/Modules/Search/Models/Result.php +++ b/app/Modules/Search/Models/Result.php @@ -6,14 +6,6 @@ /** * Model class for a search result - * - * @property string $category - * @property int $weight - * @property string $title - * @property string $text - * @property Carbon|null $created_at - * @property Carbon|null $updated_at - * @property string $route */ class Result { @@ -55,19 +47,27 @@ class Result /** * Created * - * @var string + * @var Carbon|null */ public $created_at; /** * Updated * - * @var string + * @var Carbon|null */ public $updated_at; /** * Constructor + * + * @param string $category + * @param int $weight + * @param string $title + * @param string $text + * @param string $route + * @param Carbon|null $created_at + * @param Carbon|null $updated_at */ public function __construct(string $category, int $weight, string $title, string $text, string $route, $created_at = null, $updated_at = null) { diff --git a/app/Modules/Storage/Http/Controllers/Admin/StorageController.php b/app/Modules/Storage/Http/Controllers/Admin/StorageController.php index 77cad2889..2fd278cf7 100644 --- a/app/Modules/Storage/Http/Controllers/Admin/StorageController.php +++ b/app/Modules/Storage/Http/Controllers/Admin/StorageController.php @@ -103,11 +103,13 @@ public function index(StatefulRequest $request): View */ public function create(): View { - $asset = new StorageResource; + $row = new StorageResource; $resources = (new Asset)->tree(); - $messagetypes = MessageType::query()->orderBy('name', 'asc')->get(); + $messagetypes = MessageType::query() + ->orderBy('name', 'asc') + ->get(); if ($fields = app('request')->old('fields')) { @@ -115,7 +117,7 @@ public function create(): View } return view('storage::admin.storage.edit', [ - 'row' => $asset, + 'row' => $row, 'resources' => $resources, 'messagetypes' => $messagetypes, ]); @@ -129,11 +131,13 @@ public function create(): View */ public function edit($id): View { - $asset = StorageResource::find($id); + $row = StorageResource::find($id); $resources = (new Asset)->tree(); - $messagetypes = MessageType::query()->orderBy('name', 'asc')->get(); + $messagetypes = MessageType::query() + ->orderBy('name', 'asc') + ->get(); if ($fields = app('request')->old('fields')) { @@ -141,7 +145,7 @@ public function edit($id): View } return view('storage::admin.storage.edit', [ - 'row' => $asset, + 'row' => $row, 'resources' => $resources, 'messagetypes' => $messagetypes, ]); diff --git a/app/Modules/Storage/Http/Controllers/Api/UsageController.php b/app/Modules/Storage/Http/Controllers/Api/UsageController.php index 0cfe6ef5e..0e552acb8 100644 --- a/app/Modules/Storage/Http/Controllers/Api/UsageController.php +++ b/app/Modules/Storage/Http/Controllers/Api/UsageController.php @@ -12,6 +12,7 @@ use App\Modules\Storage\Http\Resources\UsageResource; use App\Modules\Storage\Models\Usage; use App\Modules\Storage\Models\Directory; +use App\Modules\Storage\Models\StorageResource; use App\Modules\Resources\Models\Asset; use Carbon\Carbon; @@ -660,12 +661,14 @@ public function batch($resource, $dir, Request $request) } } + $user = User::findByUsername($username); + $directory = Directory::query() ->where('userid', '=', $user->id) ->where('storageresourceid', '=', $storage->id) - ->get(); + ->first(); - if (!$row->directory) + if (!$directory) { //return response()->json(['message' => trans('Invalid storagedirid specified')], 409); $messages[] = trans('Invalid storage/resource/user specified'); diff --git a/app/Modules/Storage/Listeners/GroupMembers.php b/app/Modules/Storage/Listeners/GroupMembers.php index 5cabfb487..f9452300e 100644 --- a/app/Modules/Storage/Listeners/GroupMembers.php +++ b/app/Modules/Storage/Listeners/GroupMembers.php @@ -2,8 +2,8 @@ namespace App\Modules\Storage\Listeners; use Illuminate\Events\Dispatcher; -use App\Modules\Groups\Events\GroupMemberCreated; -use App\Modules\Groups\Events\GroupMemberDeleted; +use App\Modules\Groups\Events\MemberCreated as GroupMemberCreated; +use App\Modules\Groups\Events\MemberDeleted as GroupMemberDeleted; use App\Modules\Storage\Models\Directory; use App\Modules\Storage\Models\Notification;