From d182bfe64648fb7a93a05fe5046d8afab257aa63 Mon Sep 17 00:00:00 2001
From: Alex Barth <alex_b@53995.no-reply.drupal.org>
Date: Tue, 23 Feb 2010 22:24:50 +0000
Subject: [PATCH] #718460 jerdavis: In FeedsNodeProcessor, clear items only for
 the current importer id.

---
 CHANGELOG.txt                  | 2 ++
 plugins/FeedsNodeProcessor.inc | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 77cce41c..5cdf3c36 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -4,6 +4,8 @@
 Feeds 6.x 1.0 xxxxx xx, 2010-xx-xx
 ----------------------------------
 
+- #718460 jerdavis: In FeedsNodeProcessor, clear items only for the current
+  importer id.
 - #718474 jerdavis: In FeedsNodeProcessor, check for duplicate items within
   same importer id.
 
diff --git a/plugins/FeedsNodeProcessor.inc b/plugins/FeedsNodeProcessor.inc
index 24ea7c7e..af85296b 100644
--- a/plugins/FeedsNodeProcessor.inc
+++ b/plugins/FeedsNodeProcessor.inc
@@ -98,14 +98,14 @@ class FeedsNodeProcessor extends FeedsProcessor {
    */
   public function clear(FeedsBatch $batch, FeedsSource $source) {
     if (empty($batch->total)) {
-      $batch->total = db_result(db_query("SELECT COUNT(nid) FROM {feeds_node_item} WHERE feed_nid = %d", $source->feed_nid));
+      $batch->total = db_result(db_query('SELECT COUNT(nid) FROM {feeds_node_item} WHERE id = "%s" AND feed_nid = %d', $source->id, $source->feed_nid));
     }
-    $result = db_query_range('SELECT nid FROM {feeds_node_item} WHERE feed_nid = %d', $source->feed_nid, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
+    $result = db_query_range('SELECT nid FROM {feeds_node_item} WHERE id = "%s" AND feed_nid = %d ', $source->id, $source->feed_nid, 0, variable_get('feeds_node_batch_size', FEEDS_NODE_BATCH_SIZE));
     while ($node = db_fetch_object($result)) {
       _feeds_node_delete($node->nid);
       $batch->deleted++;
     }
-    if (db_result(db_query_range('SELECT nid FROM {feeds_node_item} WHERE feed_nid = %d', $source->feed_nid, 0, 1))) {
+    if (db_result(db_query_range('SELECT nid FROM {feeds_node_item} WHERE id = "%s" AND feed_nid = %d', $source->id, $source->feed_nid, 0, 1))) {
       return (1.0 / ($batch->total + 1)) * $batch->deleted;
     }
 
-- 
GitLab