overhead; } return [ 'count' => count( $tables_to_optimize ), 'size' => $total_overhead ]; } public function purge() { $to_optimize_tables = ADBC_Tables::get_tables_to_optimize(); // get only tables names $to_optimize_tables = array_map( function ($table) { return $table->table_name; }, $to_optimize_tables ); $not_optimized = ADBC_Tables::optimize_tables( $to_optimize_tables ); return count( $to_optimize_tables ) - count( $not_optimized ); } public function list( $args ) { return []; // not used } } class ADBC_Cleanup_Repair_Tables_Handler extends ADBC_Cleanup_Tables_Handler { // Required, all tables subclasses must supply protected function items_type() { return 'tables_to_repair'; } public function count_filtered( $args = [] ) { return [ 'count' => ADBC_Tables::get_tables_to_repair()[0], 'size' => 0 // size is not applicable for optimize ]; } public function purge() { $to_repair_tables = ADBC_Tables::get_tables_to_repair()[1]; $not_repaired = ADBC_Tables::repair_tables( $to_repair_tables ); return count( $to_repair_tables ) - count( $not_repaired ); } public function list( $args ) { return []; // not used } } // Register the handlers ADBC_Cleanup_Type_Registry::register( 'tables_to_optimize', new ADBC_Cleanup_Optimize_Tables_Handler() ); ADBC_Cleanup_Type_Registry::register( 'tables_to_repair', new ADBC_Cleanup_Repair_Tables_Handler() );