You are here

function views_send_clear_spool in Views Send 8

Same name and namespace in other branches
  1. 6 views_send.cron.inc \views_send_clear_spool()
  2. 7 views_send.cron.inc \views_send_clear_spool()

Clear items from spool.

1 call to views_send_clear_spool()
views_send_cron in ./views_send.module
Implements hook_cron().

File

./views_send.cron.inc, line 75
Views Send cron rotuines.

Code

function views_send_clear_spool() {

  // Remove expired sent messages.
  $expiration_time = time() - \Drupal::config('views_send.settings')
    ->get('spool_expire') * 86400;
  \Drupal::database()
    ->query("DELETE FROM {views_send_spool} WHERE status = :status AND timestamp <= :expiry", array(
    ':status' => 1,
    'expiry' => $expiration_time,
  ));

  // Remove unsent messages which have failed more times than the retry limit.
  $retry_limit = \Drupal::config('views_send.settings')
    ->get('retry');
  \Drupal::database()
    ->query("DELETE FROM {views_send_spool} WHERE status = :status AND tentatives > :retry", array(
    ':status' => 0,
    'retry' => $retry_limit,
  ));
}