function DatabaseQueue::garbageCollection

Same name in other branches
  1. 9 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::garbageCollection()
  2. 10 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::garbageCollection()
  3. 11.x core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::garbageCollection()

Overrides QueueGarbageCollectionInterface::garbageCollection

File

core/lib/Drupal/Core/Queue/DatabaseQueue.php, line 213

Class

DatabaseQueue
Default queue implementation.

Namespace

Drupal\Core\Queue

Code

public function garbageCollection() {
    try {
        // Clean up the queue for failed batches.
        $this->connection
            ->delete(static::TABLE_NAME)
            ->condition('created', REQUEST_TIME - 864000, '<')
            ->condition('name', 'drupal_batch:%', 'LIKE')
            ->execute();
        // 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', REQUEST_TIME, '<')
            ->execute();
    } catch (\Exception $e) {
        $this->catchException($e);
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.