public function DatabaseQueue::delayItem in Drupal 10
Same name and namespace in other branches
- 9 core/lib/Drupal/Core/Queue/DatabaseQueue.php \Drupal\Core\Queue\DatabaseQueue::delayItem()
File
- core/
lib/ Drupal/ Core/ Queue/ DatabaseQueue.php, line 177
Class
- DatabaseQueue
- Default queue implementation.
Namespace
Drupal\Core\QueueCode
public function delayItem($item, int $delay) {
// Only allow a positive delay interval.
if ($delay < 0) {
throw new \InvalidArgumentException('$delay must be non-negative');
}
try {
// Add the delay relative to the current time.
$expire = \Drupal::time()
->getCurrentTime() + $delay;
// Update the expiry time of this item.
$update = $this->connection
->update(static::TABLE_NAME)
->fields([
'expire' => $expire,
])
->condition('item_id', $item->item_id);
return (bool) $update
->execute();
} catch (\Exception $e) {
$this
->catchException($e);
// If the table doesn't exist we should consider the item nonexistent.
return TRUE;
}
}