W3cubDocs

/Drupal 8

public function DatabaseQueue::garbageCollection

public DatabaseQueue::garbageCollection()

Cleans queues of garbage.

Overrides QueueGarbageCollectionInterface::garbageCollection

File

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

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(array(
        'expire' => 0,
      ))
      ->condition('expire', 0, '<>')
      ->condition('expire', REQUEST_TIME, '<')
      ->execute();
  }
  catch (\Exception $e) {
    $this->catchException($e);
  }
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Queue!DatabaseQueue.php/function/DatabaseQueue::garbageCollection/8.1.x