]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/ImportBundle/Import/AbstractImport.php
Fix tests
[github/wallabag/wallabag.git] / src / Wallabag / ImportBundle / Import / AbstractImport.php
index fc462c4cda5cac8acc66629f60bb4f148a75e583..bf568a1af4ec5a4d4a44963f7df7d0fff612cd09 100644 (file)
@@ -24,6 +24,7 @@ abstract class AbstractImport implements ImportInterface
     protected $producer;
     protected $user;
     protected $markAsRead;
+    protected $disableContentUpdate = false;
     protected $skippedEntries = 0;
     protected $importedEntries = 0;
     protected $queuedEntries = 0;
@@ -84,6 +85,26 @@ abstract class AbstractImport implements ImportInterface
         return $this->markAsRead;
     }
 
+    /**
+     * Set whether articles should be fetched for updated content.
+     *
+     * @param bool $disableContentUpdate
+     */
+    public function setDisableContentUpdate($disableContentUpdate)
+    {
+        $this->disableContentUpdate = $disableContentUpdate;
+
+        return $this;
+    }
+
+    /**
+     * Get whether articles should be fetched for updated content.
+     */
+    public function getDisableContentUpdate()
+    {
+        return $this->disableContentUpdate;
+    }
+
     /**
      * Fetch content from the ContentProxy (using graby).
      * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
@@ -94,10 +115,16 @@ abstract class AbstractImport implements ImportInterface
      */
     protected function fetchContent(Entry $entry, $url, array $content = [])
     {
+        // be sure to set at least the given url
+        $content['url'] = isset($content['url']) ? $content['url'] : $url;
+
         try {
-            $this->contentProxy->updateEntry($entry, $url, $content);
+            $this->contentProxy->importEntry($entry, $content, $this->disableContentUpdate);
         } catch (\Exception $e) {
-            return $entry;
+            $this->logger->error('Error trying to import an entry.', [
+                'entry_url' => $content['url'],
+                'error_msg' => $e->getMessage(),
+            ]);
         }
     }