public function FeedsProcessor::expire in Feeds 7.2
Same name and namespace in other branches
- 6 plugins/FeedsProcessor.inc \FeedsProcessor::expire()
- 7 plugins/FeedsProcessor.inc \FeedsProcessor::expire()
Deletes feed items older than REQUEST_TIME - $time.
Do not invoke expire on a processor directly, but use FeedsSource::expire() instead.
Parameters
FeedsSource $source: The source to expire entities for.
int|null $time: (optional) All items produced by this configuration that are older than REQUEST_TIME - $time should be deleted. If NULL, processor should use internal configuration. Defaults to NULL.
Return value
float|null FEEDS_BATCH_COMPLETE if all items have been processed, null if expiring is disabled, a float between 0 and 0.99* indicating progress otherwise.
See also
File
- plugins/
FeedsProcessor.inc, line 725 - Contains FeedsProcessor and related classes.
Class
- FeedsProcessor
- Abstract class, defines interface for processors.
Code
public function expire(FeedsSource $source, $time = NULL) {
$state = $source
->state(FEEDS_PROCESS_EXPIRE);
if ($time === NULL) {
$time = $this
->expiryTime();
}
if ($time == FEEDS_EXPIRE_NEVER) {
return;
}
$select = $this
->expiryQuery($source, $time);
// If there is no total, query it.
if (!$state->total) {
$state->total = $select
->countQuery()
->execute()
->fetchField();
}
// Delete a batch of entities.
$entity_ids = $select
->range(0, $this
->getLimit())
->execute()
->fetchCol();
if ($entity_ids) {
$this
->entityDeleteMultiple($entity_ids);
$state->deleted += count($entity_ids);
$state
->progress($state->total, $state->deleted);
}
else {
$state
->progress($state->total, $state->total);
}
}