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/registry/CheckCustomTables.php |  157 ++++++++++++++++++++++++++--------------------------
 1 files changed, 79 insertions(+), 78 deletions(-)

diff --git a/inc/registry/CheckCustomTables.php b/inc/registry/CheckCustomTables.php
index bc5955e..eaf4dbc 100644
--- a/inc/registry/CheckCustomTables.php
+++ b/inc/registry/CheckCustomTables.php
@@ -6,6 +6,7 @@
 }
 
 use Exception;
+use JVBase\registrar\Registrar;
 
 class CheckCustomTables
 {
@@ -130,13 +131,13 @@
 				error_log("JVB: Error in notification section: " . $e->getMessage());
 			}
 
-			try {
+//			try {
 //				if (array_key_exists('dashboard', $this->JVB_SITE) && $this->JVB_SITE['dashboard']) {
-					$tables = array_merge($tables, $this->queueTables(), $this->errorLogTables());
+//					$tables = array_merge($tables, $this->queueTables(), $this->errorLogTables());
 //				}
-			} catch (Exception $e) {
-				error_log("JVB: Error in dashboard section: " . $e->getMessage());
-			}
+//			} catch (Exception $e) {
+//				error_log("JVB: Error in dashboard section: " . $e->getMessage());
+//			}
 
 			try {
 				if (array_key_exists('referrals', $this->JVB_SITE) && $this->JVB_SITE['referrals']) {
@@ -440,78 +441,78 @@
      * Table Definitions
      *****************************************************/
 
-    protected function queueTables():array
-    {
-
-        return [
-		'_operation_queue' => "(
-            `id` VARCHAR(64) NOT NULL,
-            `type` varchar(50) NOT NULL,
-            `user_id` {$this->userIDType} NOT NULL,
-
-            `request_data` JSON NOT NULL CHECK (JSON_VALID(request_data)),
-
-            `total_items` int(11) NOT NULL DEFAULT 1,
-            `processed_items` int(11) DEFAULT 0,
-            `failed_items` JSON,
-
-            `priority` ENUM('high', 'normal', 'low') DEFAULT 'normal',
-            `state` enum('pending', 'scheduled', 'processing', 'completed') DEFAULT 'pending',
-            `outcome` enum('pending', 'success', 'partial', 'merged', 'failed', 'failed_permanent') DEFAULT 'pending',
-
-			`retries` int(11) DEFAULT 0,
-            `last_error_hash` CHAR(32) DEFAULT NULL,
-            `error_message` text,
-
-			`scheduled_at` datetime DEFAULT NULL,
-            `started_at` datetime DEFAULT CURRENT_TIMESTAMP,
-            `completed_at` datetime DEFAULT NULL,
-
-            `metadata` JSON DEFAULT NULL,
-            `result` JSON,
-            `dependencies` JSON,
-            `merged_into` VARCHAR(64) DEFAULT NULL,
-
-            `user_dismissed` tinyint(1) DEFAULT 0,
-            `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
-    		`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
-			PRIMARY KEY (`id`),
-		   	KEY `idx_run_queue` (state, priority, scheduled_at),
-			KEY `idx_user_ops` (user_id, state),
-			KEY `idx_user_type_pending` (user_id, type, state),
-			KEY `idx_completed_at` (completed_at),
-			KEY `idx_processing_stuck` (`state`, `started_at`)
-            )",
-
-		'stats__operation_queue' => "(
-			`id` bigint unsigned AUTO_INCREMENT,
-			`date` date NOT NULL,
-			`type` varchar(50) NOT NULL,
-
-			`total_operations` int NOT NULL DEFAULT 0,
-			`successful_operations` int NOT NULL DEFAULT 0,
-			`partial_operations` int NOT NULL DEFAULT 0,
-			`failed_operations` int NOT NULL DEFAULT 0,
-			`failed_permanent_operations` int NOT NULL DEFAULT 0,
-
-			`total_items_processed` int NOT NULL DEFAULT 0,
-
-			`average_duration` float DEFAULT NULL,
-			`max_duration` int DEFAULT NULL,
-
-			`peak_queue_size` int NOT NULL DEFAULT 0,
-
-			`peak_memory_usage` int DEFAULT NULL,
-			`peak_cpu_usage` float DEFAULT NULL,
-
-			`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
-			PRIMARY KEY (`id`),
-			UNIQUE KEY (date, type),
-			KEY `date_idx` (date),
-			KEY `type_idx` (type)
-        )"
-        ];
-    }
+//    protected function queueTables():array
+//    {
+//
+//        return [
+//		'_operation_queue' => "(
+//            `id` VARCHAR(64) NOT NULL,
+//            `type` varchar(50) NOT NULL,
+//            `user_id` {$this->userIDType} NOT NULL,
+//
+//            `request_data` JSON NOT NULL CHECK (JSON_VALID(request_data)),
+//
+//            `total_items` int(11) NOT NULL DEFAULT 1,
+//            `processed_items` int(11) DEFAULT 0,
+//            `failed_items` JSON,
+//
+//            `priority` ENUM('high', 'normal', 'low') DEFAULT 'normal',
+//            `state` enum('pending', 'scheduled', 'processing', 'completed') DEFAULT 'pending',
+//            `outcome` enum('pending', 'success', 'partial', 'merged', 'failed', 'failed_permanent') DEFAULT 'pending',
+//
+//			`retries` int(11) DEFAULT 0,
+//            `last_error_hash` CHAR(32) DEFAULT NULL,
+//            `error_message` text,
+//
+//			`scheduled_at` datetime DEFAULT NULL,
+//            `started_at` datetime DEFAULT CURRENT_TIMESTAMP,
+//            `completed_at` datetime DEFAULT NULL,
+//
+//            `metadata` JSON DEFAULT NULL,
+//            `result` JSON,
+//            `dependencies` JSON,
+//            `merged_into` VARCHAR(64) DEFAULT NULL,
+//
+//            `user_dismissed` tinyint(1) DEFAULT 0,
+//            `created_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
+//    		`updated_at` DATETIME DEFAULT CURRENT_TIMESTAMP,
+//			PRIMARY KEY (`id`),
+//		   	KEY `idx_run_queue` (state, priority, scheduled_at),
+//			KEY `idx_user_ops` (user_id, state),
+//			KEY `idx_user_type_pending` (user_id, type, state),
+//			KEY `idx_completed_at` (completed_at),
+//			KEY `idx_processing_stuck` (`state`, `started_at`)
+//            )",
+//
+//		'stats__operation_queue' => "(
+//			`id` bigint unsigned AUTO_INCREMENT,
+//			`date` date NOT NULL,
+//			`type` varchar(50) NOT NULL,
+//
+//			`total_operations` int NOT NULL DEFAULT 0,
+//			`successful_operations` int NOT NULL DEFAULT 0,
+//			`partial_operations` int NOT NULL DEFAULT 0,
+//			`failed_operations` int NOT NULL DEFAULT 0,
+//			`failed_permanent_operations` int NOT NULL DEFAULT 0,
+//
+//			`total_items_processed` int NOT NULL DEFAULT 0,
+//
+//			`average_duration` float DEFAULT NULL,
+//			`max_duration` int DEFAULT NULL,
+//
+//			`peak_queue_size` int NOT NULL DEFAULT 0,
+//
+//			`peak_memory_usage` int DEFAULT NULL,
+//			`peak_cpu_usage` float DEFAULT NULL,
+//
+//			`created_at` timestamp DEFAULT CURRENT_TIMESTAMP,
+//			PRIMARY KEY (`id`),
+//			UNIQUE KEY (date, type),
+//			KEY `date_idx` (date),
+//			KEY `type_idx` (type)
+//        )"
+//        ];
+//    }
 
 	protected function errorLogTables():array
 	{
@@ -1519,7 +1520,7 @@
 		}
 
 		try {
-			$contentFields = jvbGetFields($type);
+			$contentFields = Registrar::getFieldsFor($type);
 
 			if (!$contentFields || empty($contentFields)) {
 				return;

--
Gitblit v1.10.0