From 5a6f56dca00e88f0fe81c14b07ea7375ad0035c7 Mon Sep 17 00:00:00 2001
From: Alex Barth <alex_b@53995.no-reply.drupal.org>
Date: Wed, 15 Sep 2010 20:06:20 +0000
Subject: [PATCH] #906654 alex_b: Fix phantom subscriptions.

---
 CHANGELOG.txt            |  1 +
 includes/FeedsSource.inc | 13 ++++++++++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index efb8161a..a29fde9a 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -3,6 +3,7 @@
 Feeds 6.x xxxxxxxxxxxxxxxxxxxxxx
 --------------------------------
 
+- #906654 alex_b: Fix phantom subscriptions.
 - #867892 alex_b: PubSubHubbub - slow down import frequency of feeds that are
   subscribed to hub.
 - #908964 alex_b: Break out scheduler. Note: Features depends on Job Scheduler
diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc
index 682fdf76..b6f2a89b 100644
--- a/includes/FeedsSource.inc
+++ b/includes/FeedsSource.inc
@@ -287,13 +287,20 @@ class FeedsSource extends FeedsConfigurable {
   }
 
   /**
-   * Override existing, only return source if importer and source 'exist'.
+   * Only return source if configuration is persistent and valid.
    *
    * @see FeedsConfigurable::existing().
    */
   public function existing() {
-    $this->importer->existing();
-    return parent::existing();
+    // If there is no feed nid given, there must be no content type specified.
+    // If there is a feed nid given, there must be a content type specified.
+    // Ensure that importer is persistent (= defined in code or DB).
+    // Ensure that source is persistent (= defined in DB).
+    if ((empty($this->feed_nid) && empty($this->importer->config['content_type'])) ||
+        (!empty($this->feed_nid) && !empty($this->importer->config['content_type']))) {
+      $this->importer->existing();
+      return parent::existing();
+    }
   }
 
   /**
-- 
GitLab