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/DashboardManager.php |   77 +++++++++++++++-----------------------
 1 files changed, 31 insertions(+), 46 deletions(-)

diff --git a/inc/managers/DashboardManager.php b/inc/managers/DashboardManager.php
index 67844ec..5a25ea0 100644
--- a/inc/managers/DashboardManager.php
+++ b/inc/managers/DashboardManager.php
@@ -17,14 +17,14 @@
 class DashboardManager
 {
     protected WP_User $user;
-    protected CacheManager $cache;
+    protected Cache $cache;
     protected string $role;
 	protected string $baseURL;
     protected int $userLink;
 
     public function __construct()
     {
-        $this->cache = CacheManager::for('dashboard', WEEK_IN_SECONDS);
+        $this->cache = Cache::for('dashboard', WEEK_IN_SECONDS)->connect('user');
         add_action('init', [$this, 'registerDashboard']);
         if (!$this->isRegistered()) {
             add_action('init', [$this, 'buildDashboard']);
@@ -67,18 +67,21 @@
         $singular = 'Dashboard';
         register_post_type(BASE.'dash', array(
             'labels'                => [
-                'name' => $plural,
-                'singular_name' => $singular,
-                'menu_name' => $plural,
-                'add_new' => "Add New {$singular}",
-                'add_new_item' => "Add New {$singular}",
-                'edit_item' => "Edit {$singular}",
-                'new_item' => "New {$singular}",
-                'view_item' => "View {$singular}",
-                'search_items' => "Search {$plural}",
-                'not_found' => "No {$plural} found",
-                'not_found_in_trash' => "No {$plural} found in Trash"
-            ],
+				'name'               => $plural,
+				'singular_name'      => $singular,
+				'menu_name'          => $plural,
+				'name_admin_bar'     => $singular,
+				'add_new'            => "Add New",
+				'add_new_item'       => "Add New {$singular}",
+				'new_item'           => "New {$singular}",
+				'edit_item'          => "Edit {$singular}",
+				'view_item'          => "View {$singular}",
+				'all_items'          => "All {$plural}",
+				'search_items'       => "Search {$plural}",
+				'parent_item_colon'  => "Parent {$plural}:",
+				'not_found'          => "No {$plural} found.",
+				'not_found_in_trash' => "No {$plural} found in Trash.",
+			],
             'menu_icon'             => jvbCSSIcon('gauge'),
             'public'                => true,
             'publicly_queryable'    => true,
@@ -207,10 +210,10 @@
 			$page = $this->getCurrentPageTitle();
 			// Check if page exists in allowed pages
 			$allowedPages = $this->getUserAllowedPages();
+
 			if (!in_array($page, $allowedPages)) {
 				error_log("User not allowed to access page: {$page}");
 				$this->redirectToDashboard();
-				return;
 			}
 		}
 	}
@@ -351,14 +354,14 @@
 			// Pass along to the Integrations template handler which knows to check for subpages
 			$page = 'integrations';
 		}
-		echo $this->renderDashboard($page);
-		//TODO: Reenable
-//		echo $this->cache->remember(
-//			$page,
-//		 	function() use ($page) {
-//				return $this->renderDashboard($page);
-//		 	}
-//		);
+//		echo $this->renderDashboard($page);
+
+		echo $this->cache->remember(
+			$page,
+		 	function() use ($page) {
+				return $this->renderDashboard($page);
+		 	}
+		);
 
 		return '';
     }
@@ -595,8 +598,7 @@
         if (!$post) {
             return '';
         }
-
-        return $post->post_title;
+        return html_entity_decode($post->post_title);
     }
    protected function getCurrentPageSlug():string
     {
@@ -1345,15 +1347,14 @@
 		}
 
 
-		$cacheKey = "user_pages_{$userID}";
-		$pages = $this->cache->get($cacheKey);
-		$pages = false;
+		$pages = $this->cache->get($userID);
+
 		if ($pages === false || JVB_TESTING) {
 			if (user_can($userID, 'manage_options')) {
 				// Admin gets all pages as flat array
 				$pages = $this->getAllDashboardPages();
 				// Extract just the values (slugs)
-				$this->cache->set($cacheKey, $pages, WEEK_IN_SECONDS);
+				$this->cache->set($userID, $pages, WEEK_IN_SECONDS);
 				return $pages;
 			}
 			$roles = array_map('jvbNoBase', $user->roles);
@@ -1475,7 +1476,7 @@
 			$pages = apply_filters('jvbUserDashboardPages', $pages, $user->roles, $userID);
 			$pages = array_unique($pages);
 
-			$this->cache->set($cacheKey, $pages, WEEK_IN_SECONDS);
+			$this->cache->set($userID, $pages, WEEK_IN_SECONDS);
 		}
 
 		return $pages;
@@ -1549,20 +1550,4 @@
 		// Default to edit_{type}s
 		return 'edit_'.$type.'s';
 	}
-
-	/**
-	 * Invalidate dashboard page cache for a user or all users
-	 * Call this when user roles or permissions change
-	 * @param int|null $userID Specific user to invalidate, null for all
-	 * @return void
-	 */
-	public function invalidatePagesCache(?int $userID = null):void
-	{
-		if ($userID !== null) {
-			$this->cache->delete("user_pages_{$userID}");
-		} else {
-			// Invalidate all user caches by invalidating the group
-			$this->cache->invalidate();
-		}
-	}
 }

--
Gitblit v1.10.0