From a9654f00c8fbc9934289d761843ddd071025013f Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 28 Aug 2026 17:20:28 +0000
Subject: [PATCH] =PHPStorm Code Inspection: fixed class reference errors (from getting rid of JVB() and replacing with direct class::getInstance; as well as general code sniffing, etc
---
inc/managers/queue/Queue.php | 34 +++++++++++++++++++++++++---------
1 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/inc/managers/queue/Queue.php b/inc/managers/queue/Queue.php
index 8dd89f7..d0e359e 100644
--- a/inc/managers/queue/Queue.php
+++ b/inc/managers/queue/Queue.php
@@ -4,21 +4,32 @@
exit;
}
-use JVBase\managers\CustomTable;
+use Exception;
+use JVBase\Instance;
+use JVBase\managers\AdminPages;
+use JVBase\managers\Errors;
+use JVBase\rest\routes\QueueRoutes;
+use Throwable;
use WP_Error;
use WP_REST_Request;
use WP_REST_Response;
class Queue
{
+ use Instance;
private Storage $storage;
private Processor $processor;
private TypeRegistry $registry;
public Executor $executor;
private Locker $locker;
- public function __construct()
+ private QueueRoutes $routes;
+
+ private function __construct()
{
+ //Load routes
+ $this->routes = new QueueRoutes();
+
$this->storage = new Storage();
$this->registry = new TypeRegistry();
$this->locker = new Locker();
@@ -95,8 +106,8 @@
'updated_existing' => false,
];
- } catch (\Exception $e) {
- JVB()->error()->log('queue', $e->getMessage(), $data, 'high');
+ } catch (Exception $e) {
+ Errors::getInstance()->log('queue', $e->getMessage(), $data, 'high');
return new WP_Error('queue_failed', $e->getMessage());
}
}
@@ -104,7 +115,7 @@
/**
* Try to merge incoming operation into an existing pending/scheduled one.
* Returns result array if merged, null if not.
- * @throws \Throwable
+ * @throws Throwable
*/
private function tryMerge(Operation $incoming): ?array
{
@@ -173,7 +184,7 @@
public function maintenance(): void
{
$this->locker->withLock(function () {
- $this->storage->resetStuckOperations(30);
+ $this->storage->resetStuckOperations();
});
$this->runQueueOnShutdown();
}
@@ -196,7 +207,7 @@
/**
* Get a specific value from an operation - backwards compatibility
*/
- public function getOperationValue(string $id, string $column, bool $decodeJson = true): mixed
+ public function getOperationValue(string $id, string $column, bool $decodeJson = true): \static|string|int|array|null
{
$op = $this->get($id);
if (!$op) {
@@ -343,7 +354,7 @@
// Use provided operation_id or generate one
$op->id = !empty($options['operation_id'])
? $options['operation_id']
- : 'u' . $userId . '_' . uniqid('op_');
+ : self::generateID($userId);
$op->type = $type;
$op->userId = $userId;
@@ -422,7 +433,7 @@
public function registerAdminAction():void
{
- $admin = JVB()->admin();
+ $admin = AdminPages::getInstance();
$admin->registerAction(
'Restart Stuck Operations',
'restart-stuck-operations',
@@ -463,4 +474,9 @@
return $response;
}
}
+
+ public static function generateId(int $userID):string
+ {
+ return 'u' . $userID . '_' . uniqid('op_');
+ }
}
--
Gitblit v1.10.0