From 3d25ad7de4fdbb3eba2cde2a62422e6be5d79a0a Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Tue, 25 Aug 2026 22:57:22 +0000
Subject: [PATCH] =It's been a minute. I went through the Routes and associated Managers and ensured they played together well. Reworked the Cache.php, and I think I caught all the references. Moving away from JVBase() root class, to individuall classes that are Instanced. Double checked for the ABSPATH check in every file, and added index.php to every directory that didn't already have it. Also still working on the MenuBlock to work with WooCommerce for now for Northeh
---
inc/rest/routes/ContentRoutes.php | 38 ++++++++++++++++++++++----------------
1 files changed, 22 insertions(+), 16 deletions(-)
diff --git a/inc/rest/routes/ContentRoutes.php b/inc/rest/routes/ContentRoutes.php
index 9375fa2..7d5ef42 100644
--- a/inc/rest/routes/ContentRoutes.php
+++ b/inc/rest/routes/ContentRoutes.php
@@ -2,7 +2,10 @@
namespace JVBase\rest\routes;
+use JVBase\Instance;
+use JVBase\managers\Cache;
use JVBase\managers\queue\executors\ContentExecutor;
+use JVBase\managers\queue\Queue;
use JVBase\managers\queue\TypeConfig;
use JVBase\meta\Meta;
use JVBase\registrar\Registrar;
@@ -23,6 +26,7 @@
class ContentRoutes extends Rest
{
+ use Instance;
protected array $fields = [];
protected array $taxonomies = [];
protected string $post_type = '';
@@ -33,16 +37,21 @@
protected array $timelineUniqueFields = [];
protected static ?string $action = 'dash-';
protected Meta $meta;
+ protected Cache $termCache;
public function __construct()
{
- $this->cacheName = 'user_content_' . get_current_user_id();
+ $this->cacheName = 'user_content';
parent::__construct();
+ $this->cache = Cache::for($this->cacheName, 'post', DAY_IN_SECONDS);
+ $this->cache->user();
+ $this->termCache = Cache::for($this->cacheName.'_terms', 'term', DAY_IN_SECONDS);
+ $this->termCache->user();
+
+
if (JVB_TESTING) {
$this->cache->flush();
}
- $this->cache->connect('post', true);
- $this->cache->connect('term', true);
add_action('init', [$this, 'registerContentExecutors'], 5);
}
@@ -51,7 +60,7 @@
*/
public function registerContentExecutors(): void
{
- $registry = JVB()->queue()->registry();
+ $registry = Queue::getInstance()->registry();
$executor = new ContentExecutor();
// Content updates - chunked at 10 posts
@@ -174,7 +183,7 @@
unset($data['id']);
error_log('[CONTENT]:'.print_r($data, true));
- $queue = JVB()->queue();
+ $queue = Queue::getInstance();
$queue->queueOperation(
'content_update',
$user_id,
@@ -271,7 +280,7 @@
}
$key = $this->cache->generateKey($args);
- $cached = $this->checkCache($key, $request);
+ $cached = $this->cache->get($key);
if ($cached) {
return $cached;
}
@@ -301,8 +310,7 @@
$this->cache->set($key, $data);
- $response = Response::success($data);
- return $this->addCacheHeaders($response);
+ return Response::success($data);
}
public function getTerms(WP_REST_Request $request, array $params, Registrar $registrar):WP_REST_Response
{
@@ -337,15 +345,14 @@
$key = $this->cache->generateKey($args);
// Check HTTP cache headers with the specific content type
- $cache_check = $this->checkHeaders($request, $key);
- if ($cache_check) {
- return $cache_check;
- }
+// $cache_check = $this->checkHeaders($request, $key);
+// if ($cache_check) {
+// return $cache_check;
+// }
$cache = $this->cache->get($key);
if ($cache) {
- $response = Response::success($cache);
- return $this->addCacheHeaders($response);
+ return Response::success($cache);
}
$this->post_type = jvbCheckBase($params['content'] ?? $params['type']);
// Only expand search to taxonomies if we're actually going to query
@@ -384,8 +391,7 @@
$this->cache->set($key, $data);
- $response = Response::success($data);
- return $this->addCacheHeaders($response);
+ return Response::success($data);
}
protected function applySearchFilters(array $args, array $params): array
--
Gitblit v1.10.0