From c4aa5cdb5e90ad4b420e22772797d16980232a2b Mon Sep 17 00:00:00 2001
From: Jake Vanderwerf <get@jakevanderwerf.ca>
Date: Wed, 15 Apr 2026 18:38:55 +0000
Subject: [PATCH] =Updating custom tables to utilize CustomTable.php
---
inc/managers/ErrorHandler.php | 38 +++++++++++++++++++++++++++++++++++---
1 files changed, 35 insertions(+), 3 deletions(-)
diff --git a/inc/managers/ErrorHandler.php b/inc/managers/ErrorHandler.php
index 9e6cc9a..da34d19 100644
--- a/inc/managers/ErrorHandler.php
+++ b/inc/managers/ErrorHandler.php
@@ -24,11 +24,14 @@
'critical' => 4
];
+ protected CustomTable $table;
+
public function __construct()
{
- global $wpdb;
- $this->wpdb = $wpdb;
- $this->tableName = $wpdb->prefix . BASE . 'error_log';
+ $this->defineTables();
+// global $wpdb;
+// $this->wpdb = $wpdb;
+// $this->tableName = $wpdb->prefix . BASE . 'error_log';
add_filter(BASE.'handle_bulk_operation', [$this, 'processOperation'], 10, 3);
@@ -39,6 +42,35 @@
// add_filter(BASE.'admin_action_filter', [$this, 'adminActionFilter'], 10, 3);
}
+ public function defineTables():void
+ {
+ $table = CustomTable::for('error_log');
+ $table->setColumns([
+ 'id' => 'bigint(20) unsigned NOT NULL AUTO_INCREMENT',
+ 'error_type' => 'varchar(50) NOT NULL',
+ 'component' => 'varchar(100) NOT NULL',
+ 'method' => 'varchar(100) DEFAULT NULL',
+ 'page_url' => 'varchar(255) DEFAULT NULL',
+ 'message' => 'text NOT NULL',
+ 'context' => 'JSON',
+ 'severity' => 'ENUM(\'high\',\'normal\',\'low\') DEFAULT \'normal\'',
+ 'user_id' => $table->getUserIDType().' DEFAULT NULL',
+ 'user_was_logged_in' => 'tinyint(1) NOT NULL',
+ 'source' => 'ENUM(\'frontend\', \'backend\') NOT NULL',
+ 'created_at' => 'timestamp DEFAULT CURRENT_TIMESTAMP',
+ ]);
+
+ $table->setKeys([
+ ['key' => 'PRIMARY', 'value' => 'id'],
+ '`created_at` (`created_at`)',
+ '`component_severity_date` (`component`, `severity`, `created_at`)',
+ '`error_type_date` (`error_type`, `created_at`)',
+ '`severity_date` (`severity`, `created_at`)'
+ ]);
+
+ $table->defineTable();
+ $this->table = $table;
+ }
public function registerAdminAction():void
{
$admin = JVB()->admin();
--
Gitblit v1.10.0