From a6413da67a4579866f0fd0323ddb23a7b6b9654a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Fri, 18 Sep 2026 17:00:53 +0000
Subject: [PATCH] =Cleaning up the Integrations setup a bit, started the Helcim integration work too

---
 inc/managers/queue/Queue.php |   37 +++++++++++++++++++++++--------------
 1 files changed, 23 insertions(+), 14 deletions(-)

diff --git a/inc/managers/queue/Queue.php b/inc/managers/queue/Queue.php
index c668f4c..86ba4f9 100644
--- a/inc/managers/queue/Queue.php
+++ b/inc/managers/queue/Queue.php
@@ -4,15 +4,20 @@
 	exit;
 }
 
+use Exception;
+use JVBase\inc\managers\ErrorHelper;
 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;
+	use Instance, ErrorHelper;
 	private Storage $storage;
 	private Processor $processor;
 	private TypeRegistry $registry;
@@ -73,13 +78,15 @@
 	 * @param int $userId User ID
 	 * @param array $data Request data
 	 * @param array $options {
-	 *     @type string $priority     'low', 'normal', 'high'
-	 *     @type int $delay           Seconds to delay processing
-	 *     @type string $scheduled    Specific datetime to process
-	 *     @type array|string $depends_on  Operation IDs this depends on
-	 *     @type string|array $chunk_key   Key(s) to chunk (overrides registry)
-	 *     @type int $chunk_size      Chunk size (overrides registry)
+	 * @type string $priority 'low', 'normal', 'high'
+	 * @type int $delay Seconds to delay processing
+	 * @type string $scheduled Specific datetime to process
+	 * @type array|string $depends_on Operation IDs this depends on
+	 * @type string|array $chunk_key Key(s) to chunk (overrides registry)
+	 * @type int $chunk_size Chunk size (overrides registry)
 	 * }
+	 * @throws Throwable
+	 * @throws Throwable
 	 */
 	public function add(string $type, int $userId, array $data, array $options = []): array|WP_Error
 	{
@@ -102,8 +109,9 @@
 				'updated_existing' => false,
 			];
 
-		} catch (\Exception $e) {
-			JVB()->error()->log('queue', $e->getMessage(), $data, 'high');
+		} catch (Exception $e) {
+			$this->logError($e->getMessage(), 'add', $data);
+
 			return new WP_Error('queue_failed', $e->getMessage());
 		}
 	}
@@ -111,7 +119,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
 	{
@@ -180,7 +188,7 @@
 	public function maintenance(): void
 	{
 		$this->locker->withLock(function () {
-			$this->storage->resetStuckOperations(30);
+			$this->storage->resetStuckOperations();
 		});
 		$this->runQueueOnShutdown();
 	}
@@ -203,7 +211,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) {
@@ -443,11 +451,12 @@
 			'infinity'
 		);
 	}
+
 	/**
 	 * @param WP_REST_Response $response
+	 * @param WP_REST_Request $request
 	 * @param string $action
-	 *
-	 * @return bool|WP_REST_Response
+	 * @return WP_REST_Response|bool
 	 */
 	public function adminActionFilter(WP_REST_Response $response, WP_REST_Request $request, string $action):WP_REST_Response|bool
 	{

--
Gitblit v1.10.0