function aggregator_expire

Expires items from a feed depending on expiration settings.

Parameters

$feed: Object describing feed.

1 call to aggregator_expire()
aggregator_refresh in drupal/core/modules/aggregator/aggregator.module
Checks a news feed for new items.
1 string reference to 'aggregator_expire'
aggregator_refresh in drupal/core/modules/aggregator/aggregator.module
Checks a news feed for new items.

File

drupal/core/modules/aggregator/aggregator.processor.inc, line 189
Processor functions for the aggregator module.

Code

function aggregator_expire($feed) {
  $aggregator_clear = config('aggregator.settings')
    ->get('items.expire');
  if ($aggregator_clear != AGGREGATOR_CLEAR_NEVER) {

    // Remove all items that are older than flush item timer.
    $age = REQUEST_TIME - $aggregator_clear;
    $iids = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid AND timestamp < :timestamp', array(
      ':fid' => $feed->fid,
      ':timestamp' => $age,
    ))
      ->fetchCol();
    if ($iids) {
      db_delete('aggregator_category_item')
        ->condition('iid', $iids, 'IN')
        ->execute();
      db_delete('aggregator_item')
        ->condition('iid', $iids, 'IN')
        ->execute();
    }
  }
}