You are here

public function PushQueue::garbageCollection in Salesforce Suite 8.4

Same name and namespace in other branches
  1. 8.3 modules/salesforce_push/src/PushQueue.php \Drupal\salesforce_push\PushQueue::garbageCollection()
  2. 5.0.x modules/salesforce_push/src/PushQueue.php \Drupal\salesforce_push\PushQueue::garbageCollection()

Cleans queues of garbage.

Overrides DatabaseQueue::garbageCollection

1 call to PushQueue::garbageCollection()
PushQueue::processQueue in modules/salesforce_push/src/PushQueue.php
Given a salesforce mapping, process all its push queue entries.

File

modules/salesforce_push/src/PushQueue.php, line 608

Class

PushQueue
Salesforce push queue.

Namespace

Drupal\salesforce_push

Code

public function garbageCollection() {
  if ($this->garbageCollected) {

    // Prevent excessive garbage collection. We only need it once per request.
    return;
  }
  try {

    // Reset expired items in the default queue implementation table. If
    // that's not used, this will simply be a no-op.
    $this->connection
      ->update(static::TABLE_NAME)
      ->fields([
      'expire' => 0,
    ])
      ->condition('expire', 0, '<>')
      ->condition('expire', $this->time
      ->getRequestTime(), '<')
      ->execute();
    $this->garbageCollected = TRUE;
  } catch (\Exception $e) {
    $this
      ->catchException($e);
  }
}