You are here

protected function FeedsAtomRDFProcessor::existingItemIdGlobal in Feeds Atom 6

Add handler to find an id globally

Because our deletion feeds are not necessarily the same feed as the "create new" feed, we need to check for existing items across all feeds, not just the current feed. As long as the GUID is really unique that should not cause a problem.

@todo Refactor this once http://drupal.org/node/828176 gets resolved.

See also

FeedsNodeProcessor

1 call to FeedsAtomRDFProcessor::existingItemIdGlobal()
FeedsAtomRDFProcessor::process in plugins/FeedsAtomRDFProcessor.inc
Implementation of FeedsProcessor::process().

File

plugins/FeedsAtomRDFProcessor.inc, line 116
Contains the feeds atom RDF processor class.

Class

FeedsAtomRDFProcessor
Creates nodes from feed items.

Code

protected function existingItemIdGlobal($source_item, FeedsSource $source) {

  // Iterate through all unique targets and test whether they do already
  // exist in the database.
  foreach ($this
    ->uniqueTargets($source_item) as $target => $value) {
    switch ($target) {
      case 'url':
        $nid = db_result(db_query("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND url = '%s'", $source->id, $value));
        break;
      case 'guid':
        $nid = db_result(db_query("SELECT nid FROM {feeds_node_item} WHERE id = '%s' AND guid = '%s'", $source->id, $value));
        break;
    }
    if ($nid) {

      // Return with the first nid found.
      return $nid;
    }
  }
  return 0;
}