From b38f03c0e7218762d90fa5092696b127f24f36db Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Sun, 25 Jan 2026 07:07:26 +0000
Subject: [PATCH] =Some logical flaws in Queue.php, Queue.js, ContentExecutor.php, UploadExecutor.php - particularly with timeline ordering, frontend queue updates, etc
---
inc/managers/UserTermsManager.php | 70 ++---------------------------------
1 files changed, 4 insertions(+), 66 deletions(-)
diff --git a/inc/managers/UserTermsManager.php b/inc/managers/UserTermsManager.php
index b900dff..4673568 100644
--- a/inc/managers/UserTermsManager.php
+++ b/inc/managers/UserTermsManager.php
@@ -1,8 +1,6 @@
<?php
namespace JVBase\managers;
-use JVBase\JVB;
-use JVBase\managers\CacheManager;
use WP_Post;
use WP_Error;
use Exception;
@@ -13,7 +11,7 @@
class UserTermsManager
{
private string $table_name;
- private CacheManager $cache;
+ private Cache $cache;
private string $cacheGroup = 'user_terms_';
private int $ttl = DAY_IN_SECONDS; // 1 day default
protected \wpdb $wpdb;
@@ -41,12 +39,8 @@
*/
public function clearUserCache(int $user_id, string|null $taxonomy = null):void
{
- $cache = CacheManager::for($user_id.'_term_relationships');
- if ($taxonomy) {
- $cache->delete(jvbNoBase($taxonomy));
- } else {
- $cache->invalidate();
- }
+ $cache = Cache::for($user_id.'_term_relationships', DAY_IN_SECONDS)->connect('post', true)->connect('taxonomy', true);
+ $cache->flush();
}
// Update term usage when a post is saved
@@ -592,10 +586,9 @@
private function fetchUserTerms(int $user_id, string $taxonomy, array $args):array
{
$taxonomy = jvbCheckBase($taxonomy);
- $cache = CacheManager::for($user_id.'_term_relationships');
+ $cache = Cache::for($user_id.'_term_relationships', DAY_IN_SECONDS)->connect('post', true)->connect('taxonomy', true);
$key = $cache->generateKey(array_merge(
[
- 'user' => $user_id,
'taxonomy' => $taxonomy,
],
$args
@@ -683,59 +676,4 @@
}, $terms);
}
- /**
- * @param int $user_id
- *
- * @return bool
- */
- public function warmCache(int $user_id):bool
- {
- // Get all taxonomies
- $taxonomies = getTaxonomies(['_builtin' => false], 'names');
-
- foreach ($taxonomies as $taxonomy) {
- if (str_starts_with($taxonomy, BASE)) {
- // Pre-cache the most common queries
- $common_args = [
- // Most frequently used terms
- [
- 'orderby' => 'count',
- 'order' => 'DESC',
- 'limit' => 20,
- 'include_parents' => true
- ],
- // Recently used terms
- [
- 'orderby' => 'last_used',
- 'order' => 'DESC',
- 'limit' => 20,
- 'include_parents' => true
- ],
- // Alphabetical list
- [
- 'orderby' => 'name',
- 'order' => 'ASC',
- 'limit' => 0,
- 'include_parents' => true
- ],
- // Direct terms only (no parents)
- [
- 'orderby' => 'count',
- 'order' => 'DESC',
- 'limit' => 0,
- 'only_direct' => true
- ]
- ];
-
- foreach ($common_args as $args) {
- // Force skip_cache to ensure we get fresh data
- $args['skip_cache'] = true;
-
- // Warm the cache by executing the query
- $this->getUserTerms($user_id, $taxonomy, $args);
- }
- }
- }
- return true;
- }
}
--
Gitblit v1.10.0