get_col( $wpdb->prepare( "SELECT id FROM %i WHERE status IN ({$in}) AND finished_at IS NOT NULL AND finished_at < %s AND (summary NOT LIKE %s) LIMIT 50", $runs, $cutoff, '%items_purged_at%' ) ); // phpcs:ignore WordPress.DB, PluginCheck.Security.DirectDB -- Recast-owned table, prepared query. $repo = new RunRepository(); $count = 0; foreach ( $ids as $id ) { $wpdb->delete( Schema::table( 'run_items' ), array( 'run_id' => (int) $id ) ); // phpcs:ignore WordPress.DB, PluginCheck.Security.DirectDB -- Recast-owned table, prepared query. $wpdb->delete( Schema::table( 'run_events' ), array( 'run_id' => (int) $id ) ); // phpcs:ignore WordPress.DB, PluginCheck.Security.DirectDB -- Recast-owned table, prepared query. $repo->patch_summary( (int) $id, array( 'items_purged_at' => current_time( 'mysql', true ) ) ); ++$count; } return $count; } }