aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/PocketImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2016-09-17 07:40:56 +0200
committerJeremy Benoist <jeremy.benoist@gmail.com>2016-09-17 07:40:56 +0200
commit59b97fae996d8307b9d957d210d46200f6d206bf (patch)
tree9481859d10fafed91067ac7736480e91cd6eb4bb /src/Wallabag/ImportBundle/Import/PocketImport.php
parentfbb319f064e6336a3b44bda12cdc51c93c51f379 (diff)
downloadwallabag-59b97fae996d8307b9d957d210d46200f6d206bf.tar.gz
wallabag-59b97fae996d8307b9d957d210d46200f6d206bf.tar.zst
wallabag-59b97fae996d8307b9d957d210d46200f6d206bf.zip
Avoid losing entry when fetching fail
Instead of just say “Failed to save entry” we’ll save the entry at all cost and try to fetch content. If fetching content failed, the entry will still be saved at least, but without content.
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/PocketImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/PocketImport.php19
1 files changed, 5 insertions, 14 deletions
diff --git a/src/Wallabag/ImportBundle/Import/PocketImport.php b/src/Wallabag/ImportBundle/Import/PocketImport.php
index 1bf22d68..e00eb44b 100644
--- a/src/Wallabag/ImportBundle/Import/PocketImport.php
+++ b/src/Wallabag/ImportBundle/Import/PocketImport.php
@@ -199,24 +199,16 @@ class PocketImport extends AbstractImport
199 } 199 }
200 200
201 $entry = new Entry($this->user); 201 $entry = new Entry($this->user);
202 $entry = $this->fetchContent($entry, $url); 202 $entry->setUrl($url);
203
204 // jump to next entry in case of problem while getting content
205 if (false === $entry) {
206 ++$this->skippedEntries;
207 203
208 return; 204 // update entry with content (in case fetching failed, the given entry will be return)
209 } 205 $entry = $this->fetchContent($entry, $url);
210 206
211 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted 207 // 0, 1, 2 - 1 if the item is archived - 2 if the item should be deleted
212 if ($importedEntry['status'] == 1 || $this->markAsRead) { 208 $entry->setArchived($importedEntry['status'] == 1 || $this->markAsRead);
213 $entry->setArchived(true);
214 }
215 209
216 // 0 or 1 - 1 If the item is starred 210 // 0 or 1 - 1 If the item is starred
217 if ($importedEntry['favorite'] == 1) { 211 $entry->setStarred($importedEntry['favorite'] == 1);
218 $entry->setStarred(true);
219 }
220 212
221 $title = 'Untitled'; 213 $title = 'Untitled';
222 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') { 214 if (isset($importedEntry['resolved_title']) && $importedEntry['resolved_title'] != '') {
@@ -226,7 +218,6 @@ class PocketImport extends AbstractImport
226 } 218 }
227 219
228 $entry->setTitle($title); 220 $entry->setTitle($title);
229 $entry->setUrl($url);
230 221
231 // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image 222 // 0, 1, or 2 - 1 if the item has images in it - 2 if the item is an image
232 if (isset($importedEntry['has_image']) && $importedEntry['has_image'] > 0 && isset($importedEntry['images'][1])) { 223 if (isset($importedEntry['has_image']) && $importedEntry['has_image'] > 0 && isset($importedEntry['images'][1])) {