Tribe__Events__Aggregator__Cron::start_batch_pushing_records()
Start the processing of the scheduled imports created with batch pushing the cron job would select and start the beginning of the batch delivery.
Source
File: src/Tribe/Aggregator/Cron.php
public function start_batch_pushing_records() {
if ( ! tribe( 'events-aggregator.main' )->is_service_active() ) {
return;
}
$records = Records::instance();
$query = $this->get_batch_pushing_records();
if ( ! $query->have_posts() ) {
tribe( 'logger' )->log_debug( 'No Pending Batch to be started', 'EA Cron' );
return;
}
tribe( 'logger' )->log_debug( "Found {$query->found_posts} records", 'EA Cron' );
$cleaner = new Tribe__Events__Aggregator__Record__Queue_Cleaner();
foreach ( $query->posts as $post ) {
$record = $records->get_by_post_id( $post );
if ( null === $record || tribe_is_error( $record ) ) {
continue;
}
// Just double Check for CSV.
if ( 'csv' === $record->origin ) {
tribe( 'logger' )->log_debug( sprintf( 'Record (%d) skipped, has CSV origin', $record->id ), 'EA Cron' );
continue;
}
$cleaner->set_stall_limit( HOUR_IN_SECONDS * 22 )->set_time_to_live( HOUR_IN_SECONDS * 23 );
$cleaner->remove_duplicate_pending_records_for( $record );
$failed = $cleaner->maybe_fail_stalled_record( $record );
if ( $failed ) {
tribe( 'logger' )->log_debug( sprintf( 'Stalled record (%d) was skipped', $record->id ), 'EA Cron' );
continue;
}
$record->process_posts( [], true );
}
}
Changelog
| Version | Description |
|---|---|
| 5.3.0 | Introduced. |