@GGG@cted function mark_completed() { $state = $this->get_state(); $state['completed_at'] = current_time( 'mysql' ); $this->set_state( $state ); } /** * Increment progress counters. * * Updates processed and/or failed counts in a single operation. * Consolidates duplicate progress update logic across processors. * * @param int $processed Number of items successfully processed in this batch. * @param int $failed Number of items that failed in this batch (optional). */ protected function increment_progress( $processed = 0, $failed = 0 ) { $state = $this->get_state(); $state['processed'] = ( $state['processed'] ?? 0 ) + $processed; if ( $failed > 0 ) { $state['failed'] = ( $state['failed'] ?? 0 ) + $failed; } $this->set_state( $state ); } /** * Clear all state data. */ protected function clear_state() { delete_option( $this->get_state_option_name() ); } /** * Delete all queued batches directly from database. * * Memory-efficient alternative to cancel_process() that doesn't load batches into memory. * Uses direct SQL deletion to avoid memory exhaustion with large queues. */ protected function delete_batches_from_db() { global $wpdb; \RankMath\Helpers\DB::query( $wpdb->prepare( "DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $wpdb->esc_like( $this->identifier . '_batch_' ) . '%' ) ); } }