You are here

public function FeedsNodeProcessor::expire in Feeds 7

Same name and namespace in other branches
  1. 6 plugins/FeedsNodeProcessor.inc \FeedsNodeProcessor::expire()

Implement expire().

Overrides FeedsProcessor::expire

File

plugins/FeedsNodeProcessor.inc, line 121
Class definition of FeedsNodeProcessor.

Class

FeedsNodeProcessor
Creates nodes from feed items.

Code

public function expire($time = NULL) {
  if ($time === NULL) {
    $time = $this
      ->expiryTime();
  }
  if ($time == FEEDS_EXPIRE_NEVER) {
    return;
  }
  $count = variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE);
  $nodes = db_query_range("SELECT n.nid FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = :id AND n.created < :created", 0, $count, array(
    ':id' => $this->id,
    ':created' => REQUEST_TIME - $time,
  ));
  foreach ($nodes as $node) {
    _feeds_node_delete($node->nid);
  }
  if (db_query_range("SELECT 1 FROM {node} n JOIN {feeds_node_item} fni ON n.nid = fni.nid WHERE fni.id = :id AND n.created < :created", 0, 1, array(
    ':id' => $this->id,
    ':created' => REQUEST_TIME - $time,
  ))
    ->fetchField()) {
    return FEEDS_BATCH_ACTIVE;
  }
  return FEEDS_BATCH_COMPLETE;
}