From 772462eeca3002a1d52508aeba485aab2b4742ad Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 03 Mar 2026 19:06:19 +0000
Subject: [PATCH] =MAJOR OVERHAUL. Likely should have made a new branch ages ago. Key changes: Registrar.php is the base for custom post types, taxonomies, and user roles. Replaces JVB_CONTENT, JVB_TAXONOMY, and JVB_USER constants, eliminates most of Features.php (except for JVB_SITE, JVB_MEMBERSHIP), and has built in sanitizing and validation via sub-classes. Also started a major overhaul of the Schema output. Created a shit ton of property traits and classes to help sanitize and ensure proper data for different schema types. Still a bunch to do, but better to be starting committing changes here on this other branch.
---
inc/rest/routes/QueueRoutes.php | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/inc/rest/routes/QueueRoutes.php b/inc/rest/routes/QueueRoutes.php
index 3c27a3a..954e0a6 100644
--- a/inc/rest/routes/QueueRoutes.php
+++ b/inc/rest/routes/QueueRoutes.php
@@ -41,14 +41,15 @@
'limit' => 'integer|default:50|min:1|max:100',
])
->auth('user')
- ->rateLimit(30)
+ ->rateLimit()
->post([$this, 'handleAction'])
->args([
'ids' => 'array|required',
'action' => 'string|required|enum:dismiss,retry,cancel',
])
->auth('user')
- ->rateLimit(30);
+ ->rateLimit()
+ ->register();
// Poll endpoint
Route::for('queue/poll')
@@ -58,20 +59,23 @@
'ids' => 'string',
])
->auth('user')
- ->rateLimit(15);
+ ->rateLimit()
+ ->register();
// Errors endpoint
Route::for('queue/errors')
->get([$this, 'getOperationErrors'])
->auth('user')
- ->rateLimit(15);
+ ->rateLimit()
+ ->register();
// Single operation with dynamic ID
Route::for(Route::pattern('queue/{id}'))
->get([$this, 'getOperation'])
->arg('id', 'string|required')
->auth('user')
- ->rateLimit(15);
+ ->rateLimit()
+ ->register();
}
/**
@@ -84,6 +88,7 @@
{
$params = $request->get_params();
$user_id = absint($params['user']);
+ $this->cache = Cache::for($user_id.'_queue');
$status = sanitize_text_field($params['status']);
$ids = !empty($params['ids'])
? array_map('trim', array_map('sanitize_text_field', explode(',', $params['ids'])))
@@ -145,6 +150,8 @@
$action = sanitize_text_field($data['action'] ?? '');
$user_id = absint($data['user']);
+ $this->cache = Cache::for($user_id.'_queue');
+
// Validate input
if (empty($ids)) {
return Response::validationError(['ids' => 'Missing or invalid operation IDs']);
@@ -176,6 +183,7 @@
public function pollQueue(WP_REST_Request $request): WP_REST_Response
{
$userId = $request->get_param('user');
+ $this->cache = Cache::for($userId.'_queue');
$since = $request->get_param('since');
$ids = $request->get_param('ids');
@@ -214,6 +222,7 @@
public function getOperationErrors(WP_REST_Request $request): WP_REST_Response
{
$user_id = absint($request->get_param('user'));
+ $this->cache = Cache::for($user_id.'_queue');
$operations = JVB()->queue()->getUserOperations($user_id, [
'state' => 'completed',
'outcome' => ['failed', 'failed_permanent', 'partial'],
@@ -239,6 +248,7 @@
{
$id = $request->get_param('id');
$userId = $request->get_param('user');
+ $this->cache = Cache::for($userId.'_queue');
$op = JVB()->queue()->get($id);
--
Gitblit v1.10.0