You are here

function ip_anon_scrub in IP Anonymize 8

Same name and namespace in other branches
  1. 7 ip_anon.inc \ip_anon_scrub()

Anonymize IP addresses which have exceeded the retention period.

1 call to ip_anon_scrub()
ip_anon_cron in ./ip_anon.module
Implements hook_cron().

File

./ip_anon.inc, line 11
Page callbacks and utility functions for IP Anonymize module.

Code

function ip_anon_scrub() {
  foreach (ip_anon_tables() as $table => $columns) {
    $rows = \Drupal::database()
      ->update($table)
      ->fields([
      $columns['hostname'] => 0,
    ])
      ->condition($columns['timestamp'], \Drupal::time()
      ->getRequestTime() - \Drupal::config('ip_anon.settings')
      ->get("period_{$table}"), '<')
      ->execute();
    if (!empty($columns['callback']) && $rows) {
      $columns['callback']();
    }
  }
}