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/rest/routes/TermRoutes.php |   84 +++++++++++++++++++++--------------------
 1 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/inc/rest/routes/TermRoutes.php b/inc/rest/routes/TermRoutes.php
index ec029c8..438139e 100644
--- a/inc/rest/routes/TermRoutes.php
+++ b/inc/rest/routes/TermRoutes.php
@@ -22,7 +22,9 @@
     {
         $this->cache_name = 'terms';
         parent::__construct();
-//		$this->cache->invalidateGroup('terms');
+		if (JVB_TESTING) {
+			$this->cache->flush();
+		}
         $this->per_page = 20;
 
         add_action('edited_term', [$this, 'deleteTermPath']);
@@ -110,7 +112,7 @@
 
         $data = [
             'id' => $term->term_id,
-            'name' => $term->name,
+            'name' => html_entity_decode($term->name),
             'slug' => $term->slug,
             'taxonomy' => $term->taxonomy,
         ];
@@ -132,7 +134,7 @@
                         $term = get_term($rel->related_term_id, $rel->related_taxonomy);
                         return [
                             'id' => $rel->related_term_id,
-                            'name' => $term ? $term->name : 'Unknown',
+                            'name' => $term ? html_entity_decode($term->name) : 'Unknown',
                             'count' => $rel->relationship_count
                         ];
                     }, $relationships);
@@ -200,7 +202,7 @@
 			$args = [
 				'taxonomy'	=> $taxonomy,
 				'include'	=> $data['termIDs'],
-				'hide_empty'	=> false,
+				'hide_empty'	=> true,
 			];
 			$key = $this->cache->generateKey($args);
 			$cached = $this->cache->get($key);
@@ -241,9 +243,9 @@
                     'page' => 1,
                     'per_page' => $per_page,
                     'total_pages' => 0,
-                    'total_terms' => 0,
-                    'has_more' => false
-                ]
+                    'total_terms' => 0
+                ],
+				'has_more' => false
             ]);
         }
 
@@ -260,7 +262,7 @@
         // Get terms for current level with child count
         $args = [
             'taxonomy' => $taxonomy,
-            'hide_empty' => false,
+            'hide_empty' => true,
             'parent' => $parent,
             'number' => $per_page,
 			'orderby'=> 'name',
@@ -284,8 +286,8 @@
                         'per_page' => $per_page,
                         'total_pages' => 0,
                         'total_terms' => 0,
-                        'has_more' => false
-                    ]
+                    ],
+					'has_more' => false
                 ]);
 				return $this->addCacheHeaders($response);
             }
@@ -306,9 +308,9 @@
                         'page' => 1,
                         'per_page' => $per_page,
                         'total_pages' => 0,
-                        'total_terms' => 0,
-                        'has_more' => false
-                    ]
+                        'total_terms' => 0
+                    ],
+					'has_more' => false
                 ]);
 				return $this->addCacheHeaders($response);
             }
@@ -365,9 +367,9 @@
                         'page' => 1,
                         'per_page' => $per_page,
                         'total_pages' => 0,
-                        'total_terms' => 0,
-                        'has_more' => false
-                    ]
+                        'total_terms' => 0
+                    ],
+					'has_more' => false
                 ]);
 
 				return $this->addCacheHeaders($response);
@@ -403,9 +405,9 @@
                 'page' => $page,
                 'per_page' => $per_page,
                 'total_pages' => $total_pages,
-                'total_terms' => (int)$total_terms,
-                'has_more' => $has_more
-            ]
+                'total_terms' => (int)$total_terms
+            ],
+			'has_more' => $has_more
         ];
 
         $this->cache->set($key, $response);
@@ -442,9 +444,9 @@
 			'items'	=> $all_terms,
 			'pagination'=> [
 				'page' => $page,
-				'per_page'=> $per_page,
-				'has_more' => true,
-			]
+				'per_page'=> $per_page
+			],
+			'has_more' => true,
 		];
 
 		$response = new WP_REST_Response($response);
@@ -496,7 +498,7 @@
 		return $this->cache->remember($cache_key, function() use ($term, $taxonomy) {
 			$data = [
 				'id' => $term->term_id,
-				'name' => $term->name,
+				'name' => html_entity_decode($term->name),
 				'slug' => $term->slug,
 				'parent' => $term->parent,
 				'path' => $this->getTermPath($term->term_id, $term->name, $taxonomy),
@@ -533,7 +535,7 @@
         // When searching, we want to search across all terms regardless of hierarchy
         $args = [
             'taxonomy' => $taxonomy,
-            'hide_empty' => false,
+            'hide_empty' => true,
             'search' => $search,
             'search_columns' => ['name', 'slug'],
             'fields' => 'all',
@@ -556,9 +558,9 @@
                     'page' => 0,
                     'per_page' => 20,
                     'total_pages' => 0,
-                    'total_terms' => 0,
-                    'has_more' => false
-                ]
+                    'total_terms' => 0
+                ],
+				'has_more' => false
             ]);
         }
 
@@ -582,9 +584,9 @@
                 'page' => (int)$page,
                 'per_page' => (int)$per_page,
                 'total_pages' => $total_pages,
-                'total_terms' => (int)$total_terms,
-                'has_more' => $has_more
-            ]
+                'total_terms' => (int)$total_terms
+            ],
+			'has_more' => $has_more
         ];
 
         $this->cache->set($key, $response);
@@ -776,9 +778,9 @@
                     'page'      => (int)$page,
                     'per_page'  => (int)$per_page,
                     'total_terms'=> $total,
-                    'total_pages'=> $total_pages,
-                    'has_more'  => $page < $total_pages
-                ]
+                    'total_pages'=> $total_pages
+                ],
+				'has_more'  => $page < $total_pages
             ];
 
             // Cache results
@@ -817,7 +819,7 @@
             // Build query args
             $args = [
                 'taxonomy' => $taxonomy,
-                'hide_empty' => false,
+                'hide_empty' => true,
                 'orderby' => $search ? 'name' : 'count',
                 'order' => $search ? 'ASC' : 'DESC',
                 'number' => $per_page,
@@ -840,9 +842,9 @@
                         'page' => 0,
                         'per_page' => 20,
                         'total_pages' => 0,
-                        'total_terms' => 0,
-                        'has_more' => 0
-                    ]
+                        'total_terms' => 0
+                    ],
+					'has_more' => 0
                 ]);
             }
 
@@ -866,9 +868,9 @@
                     'page' => (int)$page,
                     'per_page' => (int)$per_page,
                     'total_pages' => $total_pages,
-                    'total_terms' => (int)$total,
-                    'has_more' => $page < $total_pages
-                ]
+                    'total_terms' => (int)$total
+                ],
+				'has_more' => $page < $total_pages
             ];
 
             // Cache results
@@ -910,7 +912,7 @@
                     'message' => 'Term already exists',
                     'term' => [
                         'id' => $term->term_id,
-                        'name' => $term->name,
+                        'name' => html_entity_decode($term->name),
                         'path' => $this->getTermPath($term->term_id, $term->name, $taxonomy)
                     ]
                 ]);

--
Gitblit v1.10.0