// otherwise, we need iterate over the entire result set in batches
$iterator = newRepositoryIterator($this->mediaRepo, $context, $criteria); while(($ids = $iterator->fetchIds()) !== null){ $ids = $this->filterOutNewMedia($ids, $gracePeriodDays); $unusedIds = $this->dispatchEvent($ids);