Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DatabaseQueue.php

function DatabaseQueue::garbageCollection

Overrides QueueGarbageCollectionInterface::garbageCollection

File

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

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', \Drupal::time()->getRequestTime() - 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', \Drupal::time()->getRequestTime(), '<')
            ->execute();
    } catch (\Exception $e) {
        $this->catchException($e);
    }
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal