From dd038fe1428defcc4eaa009bed2de25a700c50c4 Mon Sep 17 00:00:00 2001
From: grahamC <grahamC@364457.no-reply.drupal.org>
Date: Tue, 8 Dec 2015 22:22:11 +0100
Subject: [PATCH] Issue #2624344 by grahamC, MegaChriz: Import via pushImport()
 keeps looping / never completes

---
 includes/FeedsSource.inc        |  2 +-
 tests/feeds_processor_node.test | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/includes/FeedsSource.inc b/includes/FeedsSource.inc
index bb03d0ed..8349b312 100644
--- a/includes/FeedsSource.inc
+++ b/includes/FeedsSource.inc
@@ -134,7 +134,7 @@ class FeedsState {
       $this->progress = FEEDS_BATCH_COMPLETE;
     }
     elseif ($total) {
-      $this->progress = $progress / $total;
+      $this->progress = (float) $progress / $total;
       if ($this->progress == FEEDS_BATCH_COMPLETE && $total != $progress) {
         $this->progress = 0.99;
       }
diff --git a/tests/feeds_processor_node.test b/tests/feeds_processor_node.test
index c72cff29..8c1893a9 100644
--- a/tests/feeds_processor_node.test
+++ b/tests/feeds_processor_node.test
@@ -668,6 +668,26 @@ class FeedsRSStoNodesTest extends FeedsWebTestCase {
     $this->assertEqual(10, db_query("SELECT COUNT(*) FROM {node}")->fetchField());
   }
 
+  /**
+   * Tests the FeedsSource::pushImport() method with a CSV file.
+   */
+  public function testPushImportWithCSV() {
+    // Attach to standalone importer and configure.
+    $this->setSettings('syndication', NULL, array('content_type' => ''));
+    $this->setPlugin('syndication', 'FeedsCSVParser');
+    $this->removeMappings('syndication', $this->getCurrentMappings('syndication'));
+    $this->addMappings('syndication', array(
+      0 => array(
+        'source' => 'title',
+        'target' => 'title',
+      ),
+    ));
+
+    $raw = file_get_contents($this->absolutePath() . '/tests/feeds/many_nodes.csv');
+    feeds_source('syndication', 0)->pushImport(new FeedsFetcherResult($raw));
+    $this->assertEqual(86, db_query("SELECT COUNT(*) FROM {node}")->fetchField());
+  }
+
   /**
    * Tests if target item is not updated when only non-mapped data on the source changed.
    */
-- 
GitLab