Jake Vanderwerf
2026-08-26 ccf5e61a075c35d24befc175994b5cb8957ca322
inc/managers/queue/Queue.php
@@ -4,21 +4,29 @@
   exit;
}
use JVBase\managers\CustomTable;
use JVBase\Instance;
use JVBase\managers\Errors;
use JVBase\rest\routes\QueueRoutes;
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();
@@ -96,7 +104,7 @@
         ];
      } catch (\Exception $e) {
         JVB()->error()->log('queue', $e->getMessage(), $data, 'high');
         Errors::getInstance()->log('queue', $e->getMessage(), $data, 'high');
         return new WP_Error('queue_failed', $e->getMessage());
      }
   }
@@ -343,7 +351,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 +430,7 @@
   public function registerAdminAction():void
   {
      $admin = JVB()->admin();
      $admin = AdminPages::getInstance();
      $admin->registerAction(
         'Restart Stuck Operations',
         'restart-stuck-operations',
@@ -463,4 +471,9 @@
            return $response;
      }
   }
   public static function generateId(int $userID):string
   {
      return 'u' . $userID . '_' . uniqid('op_');
   }
}