You are here

public function FeedsSource::scheduleExpire in Feeds 7.2

Schedule background expire tasks.

Parameters

bool $force: (optional) If true, forces the scheduling to happen. Defaults to true.

2 calls to FeedsSource::scheduleExpire()
FeedsSource::ensureSchedule in includes/FeedsSource.inc
Schedule all periodic tasks for this source if not already scheduled.
FeedsSource::schedule in includes/FeedsSource.inc
Schedule all periodic tasks for this source, even when scheduled before.

File

includes/FeedsSource.inc, line 445
Definition of FeedsSourceInterface, FeedsState and FeedsSource class.

Class

FeedsSource
Holds the source of a feed to import.

Code

public function scheduleExpire($force = TRUE) {

  // Schedule as soon as possible if a batch is active.
  $period = $this
    ->progressExpiring() === FEEDS_BATCH_COMPLETE ? 3600 : 0;
  $job = array(
    'type' => $this->id,
    'id' => $this->feed_nid,
    'period' => $period,
    'periodic' => TRUE,
  );
  if ($this->importer->processor
    ->expiryTime() == FEEDS_EXPIRE_NEVER) {
    JobScheduler::get('feeds_source_expire')
      ->remove($job);
  }
  else {

    // Check for an existing job first.
    $existing = JobScheduler::get('feeds_source_expire')
      ->check($job);
    if (!$existing || $force) {

      // If there is no existing job, schedule a new job.
      JobScheduler::get('feeds_source_expire')
        ->set($job);
    }
    elseif ($existing['scheduled']) {

      // If the previous job is still marked as 'running', reschedule it.
      JobScheduler::get('feeds_source_expire')
        ->reschedule($existing);
    }
  }
}