'dsgo_form_submission', 'post_status' => 'any', 'fields' => 'ids', 'posts_per_page' => self::SWEEP_LIMIT, 'orderby' => 'date', 'order' => 'ASC', 'no_found_rows' => true, 'meta_key' => '_dsg_webhook_status', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key -- Bounded daily sweep. 'meta_value' => 'pending', // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_value -- Bounded daily sweep. 'date_query' => array( array( 'column' => 'post_date_gmt', 'before' => gmdate( 'Y-m-d H:i:s', time() - self::IN_FLIGHT_SECONDS ), // UTC, matching the column. ), ), ) ); update_meta_cache( 'post', $ids ); $scheduled = 0; foreach ( $ids as $id ) { $args = array( (int) $id ); if ( (int) get_post_meta( (int) $id, '_dsg_webhook_last_attempt', true ) > time() - self::IN_FLIGHT_SECONDS || false !== wp_next_scheduled( Form_Webhooks::RETRY_HOOK, $args ) ) { continue; } if ( wp_schedule_single_event( time() + $scheduled * self::SWEEP_SPACING, Form_Webhooks::RETRY_HOOK, $args ) ) { ++$scheduled; } } return $scheduled; } }