| | |
| | | '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); |
| | | |
| | |
| | | // 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(); |