Jake Vanderwerf
2026-04-15 c4aa5cdb5e90ad4b420e22772797d16980232a2b
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();