You are here

function cas_cron in CAS 8

Same name and namespace in other branches
  1. 7 cas.module \cas_cron()
  2. 2.x cas.module \cas_cron()

Implements hook_cron().

Delete stale, unused PGTs.

File

./cas.module, line 18
Provides CAS authentication for Drupal.

Code

function cas_cron() {

  // PGTs older than one hour get discarded.
  \Drupal::database()
    ->delete('cas_pgt_storage')
    ->condition('timestamp', time() - 3600, '<=')
    ->execute();

  // Clear old single logout session mapping data.
  $max_days = \Drupal::configFactory()
    ->get('cas.settings')
    ->get('logout.single_logout_session_lifetime');
  $seconds_in_day = 86400;
  $seconds = $max_days * $seconds_in_day;
  if ($seconds > 0) {
    \Drupal::database()
      ->delete('cas_login_data')
      ->condition('created', time() - $seconds, '<=')
      ->execute();
  }
}