diff options
18 files changed, 73 insertions, 84 deletions
diff --git a/src/Wallabag/CoreBundle/Controller/EntryController.php b/src/Wallabag/CoreBundle/Controller/EntryController.php index 624576b5..40111af0 100644 --- a/src/Wallabag/CoreBundle/Controller/EntryController.php +++ b/src/Wallabag/CoreBundle/Controller/EntryController.php | |||
@@ -17,26 +17,35 @@ use Sensio\Bundle\FrameworkExtraBundle\Configuration\Cache; | |||
17 | class EntryController extends Controller | 17 | class EntryController extends Controller |
18 | { | 18 | { |
19 | /** | 19 | /** |
20 | * @param Entry $entry | 20 | * Fetch content and update entry. |
21 | * In case it fails, entry will return to avod loosing the data. | ||
22 | * | ||
23 | * @param Entry $entry | ||
24 | * @param string $prefixMessage Should be the translation key: entry_saved or entry_reloaded | ||
25 | * | ||
26 | * @return Entry | ||
21 | */ | 27 | */ |
22 | private function updateEntry(Entry $entry) | 28 | private function updateEntry(Entry $entry, $prefixMessage = 'entry_saved') |
23 | { | 29 | { |
30 | // put default title in case of fetching content failed | ||
31 | $entry->setTitle('No title found'); | ||
32 | |||
33 | $message = 'flashes.entry.notice.'.$prefixMessage; | ||
34 | |||
24 | try { | 35 | try { |
25 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); | 36 | $entry = $this->get('wallabag_core.content_proxy')->updateEntry($entry, $entry->getUrl()); |
26 | |||
27 | $em = $this->getDoctrine()->getManager(); | ||
28 | $em->persist($entry); | ||
29 | $em->flush(); | ||
30 | } catch (\Exception $e) { | 37 | } catch (\Exception $e) { |
31 | $this->get('logger')->error('Error while saving an entry', [ | 38 | $this->get('logger')->error('Error while saving an entry', [ |
32 | 'exception' => $e, | 39 | 'exception' => $e, |
33 | 'entry' => $entry, | 40 | 'entry' => $entry, |
34 | ]); | 41 | ]); |
35 | 42 | ||
36 | return false; | 43 | $message = 'flashes.entry.notice.'.$prefixMessage.'_failed'; |
37 | } | 44 | } |
38 | 45 | ||
39 | return true; | 46 | $this->get('session')->getFlashBag()->add('notice', $message); |
47 | |||
48 | return $entry; | ||
40 | } | 49 | } |
41 | 50 | ||
42 | /** | 51 | /** |
@@ -66,12 +75,11 @@ class EntryController extends Controller | |||
66 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); | 75 | return $this->redirect($this->generateUrl('view', ['id' => $existingEntry->getId()])); |
67 | } | 76 | } |
68 | 77 | ||
69 | $message = 'flashes.entry.notice.entry_saved'; | 78 | $this->updateEntry($entry); |
70 | if (false === $this->updateEntry($entry)) { | ||
71 | $message = 'flashes.entry.notice.entry_saved_failed'; | ||
72 | } | ||
73 | 79 | ||
74 | $this->get('session')->getFlashBag()->add('notice', $message); | 80 | $em = $this->getDoctrine()->getManager(); |
81 | $em->persist($entry); | ||
82 | $em->flush(); | ||
75 | 83 | ||
76 | return $this->redirect($this->generateUrl('homepage')); | 84 | return $this->redirect($this->generateUrl('homepage')); |
77 | } | 85 | } |
@@ -95,6 +103,10 @@ class EntryController extends Controller | |||
95 | 103 | ||
96 | if (false === $this->checkIfEntryAlreadyExists($entry)) { | 104 | if (false === $this->checkIfEntryAlreadyExists($entry)) { |
97 | $this->updateEntry($entry); | 105 | $this->updateEntry($entry); |
106 | |||
107 | $em = $this->getDoctrine()->getManager(); | ||
108 | $em->persist($entry); | ||
109 | $em->flush(); | ||
98 | } | 110 | } |
99 | 111 | ||
100 | return $this->redirect($this->generateUrl('homepage')); | 112 | return $this->redirect($this->generateUrl('homepage')); |
@@ -316,15 +328,11 @@ class EntryController extends Controller | |||
316 | { | 328 | { |
317 | $this->checkUserAction($entry); | 329 | $this->checkUserAction($entry); |
318 | 330 | ||
319 | $message = 'flashes.entry.notice.entry_reloaded'; | 331 | $this->updateEntry($entry, 'entry_reloaded'); |
320 | if (false === $this->updateEntry($entry)) { | ||
321 | $message = 'flashes.entry.notice.entry_reload_failed'; | ||
322 | } | ||
323 | 332 | ||
324 | $this->get('session')->getFlashBag()->add( | 333 | $em = $this->getDoctrine()->getManager(); |
325 | 'notice', | 334 | $em->persist($entry); |
326 | $message | 335 | $em->flush(); |
327 | ); | ||
328 | 336 | ||
329 | return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); | 337 | return $this->redirect($this->generateUrl('view', ['id' => $entry->getId()])); |
330 | } | 338 | } |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml index 0a7c6e8c..9f051edb 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.da.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | # entry_already_saved: 'Entry already saved on %date%' | 415 | # entry_already_saved: 'Entry already saved on %date%' |
416 | # entry_saved: 'Entry saved' | 416 | # entry_saved: 'Entry saved' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | # entry_reloaded: 'Entry reloaded' | 419 | # entry_reloaded: 'Entry reloaded' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artikel arkiveret' | 421 | entry_archived: 'Artikel arkiveret' |
422 | entry_unarchived: 'Artikel ikke længere arkiveret' | 422 | entry_unarchived: 'Artikel ikke længere arkiveret' |
423 | entry_starred: 'Artikel markeret som favorit' | 423 | entry_starred: 'Artikel markeret som favorit' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml index a400686e..cbfacd55 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.de.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' | 415 | entry_already_saved: 'Eintrag bereits am %date% gespeichert' |
416 | entry_saved: 'Eintrag gespeichert' | 416 | entry_saved: 'Eintrag gespeichert' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Eintrag aktualisiert' | 418 | entry_updated: 'Eintrag aktualisiert' |
419 | entry_reloaded: 'Eintrag neugeladen' | 419 | entry_reloaded: 'Eintrag neugeladen' |
420 | entry_reload_failed: 'Neuladen des Eintrags fehlgeschlagen' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artikel archiviert' | 421 | entry_archived: 'Artikel archiviert' |
422 | entry_unarchived: 'Artikel dearchiviert' | 422 | entry_unarchived: 'Artikel dearchiviert' |
423 | entry_starred: 'Artikel favorisiert' | 423 | entry_starred: 'Artikel favorisiert' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml index 2d097caf..21e2405c 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.en.yml | |||
@@ -416,10 +416,10 @@ flashes: | |||
416 | notice: | 416 | notice: |
417 | entry_already_saved: 'Entry already saved on %date%' | 417 | entry_already_saved: 'Entry already saved on %date%' |
418 | entry_saved: 'Entry saved' | 418 | entry_saved: 'Entry saved' |
419 | entry_saved_failed: 'Failed to save entry' | 419 | entry_saved_failed: 'Entry saved but fetching content failed' |
420 | entry_updated: 'Entry updated' | 420 | entry_updated: 'Entry updated' |
421 | entry_reloaded: 'Entry reloaded' | 421 | entry_reloaded: 'Entry reloaded' |
422 | entry_reload_failed: 'Failed to reload entry' | 422 | entry_reload_failed: 'Entry reloaded but fetching content failed' |
423 | entry_archived: 'Entry archived' | 423 | entry_archived: 'Entry archived' |
424 | entry_unarchived: 'Entry unarchived' | 424 | entry_unarchived: 'Entry unarchived' |
425 | entry_starred: 'Entry starred' | 425 | entry_starred: 'Entry starred' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml index 1dbff022..43f376d4 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.es.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Entrada ya guardada por %fecha%' | 415 | entry_already_saved: 'Entrada ya guardada por %fecha%' |
416 | entry_saved: 'Entrada guardada' | 416 | entry_saved: 'Entrada guardada' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Entrada actualizada' | 418 | entry_updated: 'Entrada actualizada' |
419 | entry_reloaded: 'Entrada recargada' | 419 | entry_reloaded: 'Entrada recargada' |
420 | entry_reload_failed: 'Entrada recargada reprobada' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Artículo archivado' | 421 | entry_archived: 'Artículo archivado' |
422 | entry_unarchived: 'Artículo desarchivado' | 422 | entry_unarchived: 'Artículo desarchivado' |
423 | entry_starred: 'Artículo guardado en los favoritos' | 423 | entry_starred: 'Artículo guardado en los favoritos' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml index ad13c940..56418ef9 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fa.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' | 415 | entry_already_saved: 'این مقاله در تاریخ %date% ذخیره شده بود' |
416 | entry_saved: 'مقاله ذخیره شد' | 416 | entry_saved: 'مقاله ذخیره شد' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'مقاله بهروز شد' | 418 | entry_updated: 'مقاله بهروز شد' |
419 | entry_reloaded: 'مقاله بهروز شد' | 419 | entry_reloaded: 'مقاله بهروز شد' |
420 | entry_reload_failed: 'بهروزرسانی مقاله شکست خورد' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'مقاله بایگانی شد' | 421 | entry_archived: 'مقاله بایگانی شد' |
422 | entry_unarchived: 'مقاله از بایگانی درآمد' | 422 | entry_unarchived: 'مقاله از بایگانی درآمد' |
423 | entry_starred: 'مقاله برگزیده شد' | 423 | entry_starred: 'مقاله برگزیده شد' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml index 35e5c9d0..bde21866 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.fr.yml | |||
@@ -416,10 +416,10 @@ flashes: | |||
416 | notice: | 416 | notice: |
417 | entry_already_saved: 'Article déjà sauvergardé le %date%' | 417 | entry_already_saved: 'Article déjà sauvergardé le %date%' |
418 | entry_saved: 'Article enregistré' | 418 | entry_saved: 'Article enregistré' |
419 | entry_saved_failed: "L'enregistrement a échoué" | 419 | entry_saved_failed: 'Article enregistré mais impossible de récupérer le contenu' |
420 | entry_updated: 'Article mis à jour' | 420 | entry_updated: 'Article mis à jour' |
421 | entry_reloaded: 'Article rechargé' | 421 | entry_reloaded: 'Article rechargé' |
422 | entry_reload_failed: "Le rechargement de l'article a échoué" | 422 | entry_reload_failed: "Article mis à jour mais impossible de récupérer le contenu" |
423 | entry_archived: 'Article marqué comme lu' | 423 | entry_archived: 'Article marqué comme lu' |
424 | entry_unarchived: 'Article marqué comme non lu' | 424 | entry_unarchived: 'Article marqué comme non lu' |
425 | entry_starred: 'Article ajouté dans les favoris' | 425 | entry_starred: 'Article ajouté dans les favoris' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml index 5bc896c3..26bb31ba 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.it.yml | |||
@@ -413,10 +413,10 @@ flashes: | |||
413 | notice: | 413 | notice: |
414 | entry_already_saved: 'Contenuto già salvato in data %date%' | 414 | entry_already_saved: 'Contenuto già salvato in data %date%' |
415 | entry_saved: 'Contenuto salvato' | 415 | entry_saved: 'Contenuto salvato' |
416 | # entry_saved_failed: 'Failed to save entry' | 416 | # entry_saved_failed: 'Entry saved but fetching content failed' |
417 | entry_updated: 'Contenuto aggiornato' | 417 | entry_updated: 'Contenuto aggiornato' |
418 | entry_reloaded: 'Contenuto ricaricato' | 418 | entry_reloaded: 'Contenuto ricaricato' |
419 | entry_reload_failed: 'Errore nel ricaricamento del contenuto' | 419 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
420 | entry_archived: 'Contenuto archiviato' | 420 | entry_archived: 'Contenuto archiviato' |
421 | entry_unarchived: 'Contenuto dis-archiviato' | 421 | entry_unarchived: 'Contenuto dis-archiviato' |
422 | entry_starred: 'Contenuto segnato come preferito' | 422 | entry_starred: 'Contenuto segnato come preferito' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml index b0194c59..2c4df867 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.oc.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Article ja salvargardat lo %date%' | 415 | entry_already_saved: 'Article ja salvargardat lo %date%' |
416 | entry_saved: 'Article enregistrat' | 416 | entry_saved: 'Article enregistrat' |
417 | entry_saved_failed: "Fracàs de l'enregistrament de l'entrada" | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Article mes a jorn' | 418 | entry_updated: 'Article mes a jorn' |
419 | entry_reloaded: 'Article recargat' | 419 | entry_reloaded: 'Article recargat' |
420 | entry_reload_failed: "Fracàs de l'actualizacion de l'article" | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Article marcat coma legit' | 421 | entry_archived: 'Article marcat coma legit' |
422 | entry_unarchived: 'Article marcat coma pas legit' | 422 | entry_unarchived: 'Article marcat coma pas legit' |
423 | entry_starred: 'Article apondut dins los favorits' | 423 | entry_starred: 'Article apondut dins los favorits' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml index 6412ad16..fb821966 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.pl.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Wpis już został dodany %date%' | 415 | entry_already_saved: 'Wpis już został dodany %date%' |
416 | entry_saved: 'Wpis zapisany' | 416 | entry_saved: 'Wpis zapisany' |
417 | entry_saved_failed: 'Zapis artykułu się nie powiódł' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | entry_updated: 'Wpis zaktualizowany' | 418 | entry_updated: 'Wpis zaktualizowany' |
419 | entry_reloaded: 'Wpis ponownie załadowany' | 419 | entry_reloaded: 'Wpis ponownie załadowany' |
420 | entry_reload_failed: 'Błąd ponownego załadowania' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Wpis dodany do archiwum' | 421 | entry_archived: 'Wpis dodany do archiwum' |
422 | entry_unarchived: 'Wpis usunięty z archiwum' | 422 | entry_unarchived: 'Wpis usunięty z archiwum' |
423 | entry_starred: 'Wpis oznaczony gwiazdką' | 423 | entry_starred: 'Wpis oznaczony gwiazdką' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml index 11b744c7..3d22e29d 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.ro.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | # entry_already_saved: 'Entry already saved on %date%' | 415 | # entry_already_saved: 'Entry already saved on %date%' |
416 | # entry_saved: 'Entry saved' | 416 | # entry_saved: 'Entry saved' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | # entry_reloaded: 'Entry reloaded' | 419 | # entry_reloaded: 'Entry reloaded' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Articol arhivat' | 421 | entry_archived: 'Articol arhivat' |
422 | entry_unarchived: 'Articol dezarhivat' | 422 | entry_unarchived: 'Articol dezarhivat' |
423 | entry_starred: 'Articol adăugat la favorite' | 423 | entry_starred: 'Articol adăugat la favorite' |
diff --git a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml index d6aaacfe..5099b002 100644 --- a/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml +++ b/src/Wallabag/CoreBundle/Resources/translations/messages.tr.yml | |||
@@ -414,10 +414,10 @@ flashes: | |||
414 | notice: | 414 | notice: |
415 | entry_already_saved: 'Entry already saved on %date%' | 415 | entry_already_saved: 'Entry already saved on %date%' |
416 | entry_saved: 'Makale kaydedildi' | 416 | entry_saved: 'Makale kaydedildi' |
417 | # entry_saved_failed: 'Failed to save entry' | 417 | # entry_saved_failed: 'Entry saved but fetching content failed' |
418 | # entry_updated: 'Entry updated' | 418 | # entry_updated: 'Entry updated' |
419 | entry_reloaded: 'Makale içeriği yenilendi' | 419 | entry_reloaded: 'Makale içeriği yenilendi' |
420 | # entry_reload_failed: 'Failed to reload entry' | 420 | # entry_reload_failed: 'Entry reloaded but fetching content failed' |
421 | entry_archived: 'Makale arşivlendi' | 421 | entry_archived: 'Makale arşivlendi' |
422 | entry_unarchived: 'Makale arşivden çıkartıldı' | 422 | entry_unarchived: 'Makale arşivden çıkartıldı' |
423 | entry_starred: 'Makale favorilere eklendi' | 423 | entry_starred: 'Makale favorilere eklendi' |
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php index 2af0e69b..a1a14576 100644 --- a/src/Wallabag/ImportBundle/Import/AbstractImport.php +++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php | |||
@@ -79,20 +79,20 @@ abstract class AbstractImport implements ImportInterface | |||
79 | 79 | ||
80 | /** | 80 | /** |
81 | * Fetch content from the ContentProxy (using graby). | 81 | * Fetch content from the ContentProxy (using graby). |
82 | * If it fails return false instead of the updated entry. | 82 | * If it fails return the given entry to be saved in all case (to avoid user to loose the content). |
83 | * | 83 | * |
84 | * @param Entry $entry Entry to update | 84 | * @param Entry $entry Entry to update |
85 | * @param string $url Url to grab content for | 85 | * @param string $url Url to grab content for |
86 | * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url | 86 | * @param array $content An array with AT LEAST keys title, html, url, language & content_type to skip the fetchContent from the url |
87 | * | 87 | * |
88 | * @return Entry|false | 88 | * @return Entry |
89 | */ | 89 | */ |
90 | protected function fetchContent(Entry $entry, $url, array $content = []) | 90 | protected function fetchContent(Entry $entry, $url, array $content = []) |
91 | { | 91 | { |
92 | try { | 92 | try { |
93 | return $this->contentProxy->updateEntry($entry, $url, $content); | 93 | return $this->contentProxy->updateEntry($entry, $url, $content); |
94 | } catch (\Exception $e) { | 94 | } catch (\Exception $e) { |
95 | return false; | 95 | return $entry; |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
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])) { |
diff --git a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php index b852f8f0..fa2b7053 100644 --- a/src/Wallabag/ImportBundle/Import/ReadabilityImport.php +++ b/src/Wallabag/ImportBundle/Import/ReadabilityImport.php | |||
@@ -103,18 +103,12 @@ class ReadabilityImport extends AbstractImport | |||
103 | 'created_at' => $importedEntry['date_added'], | 103 | 'created_at' => $importedEntry['date_added'], |
104 | ]; | 104 | ]; |
105 | 105 | ||
106 | $entry = $this->fetchContent( | 106 | $entry = new Entry($this->user); |
107 | new Entry($this->user), | 107 | $entry->setUrl($data['url']); |
108 | $data['url'], | 108 | $entry->setTitle($data['title']); |
109 | $data | ||
110 | ); | ||
111 | |||
112 | // jump to next entry in case of problem while getting content | ||
113 | if (false === $entry) { | ||
114 | ++$this->skippedEntries; | ||
115 | 109 | ||
116 | return; | 110 | // update entry with content (in case fetching failed, the given entry will be return) |
117 | } | 111 | $entry = $this->fetchContent($entry, $data['url'], $data); |
118 | 112 | ||
119 | $entry->setArchived($data['is_archived']); | 113 | $entry->setArchived($data['is_archived']); |
120 | $entry->setStarred($data['is_starred']); | 114 | $entry->setStarred($data['is_starred']); |
diff --git a/src/Wallabag/ImportBundle/Import/WallabagImport.php b/src/Wallabag/ImportBundle/Import/WallabagImport.php index 969a6a04..043bb0a2 100644 --- a/src/Wallabag/ImportBundle/Import/WallabagImport.php +++ b/src/Wallabag/ImportBundle/Import/WallabagImport.php | |||
@@ -101,18 +101,12 @@ abstract class WallabagImport extends AbstractImport | |||
101 | 101 | ||
102 | $data = $this->prepareEntry($importedEntry); | 102 | $data = $this->prepareEntry($importedEntry); |
103 | 103 | ||
104 | $entry = $this->fetchContent( | 104 | $entry = new Entry($this->user); |
105 | new Entry($this->user), | 105 | $entry->setUrl($data['url']); |
106 | $importedEntry['url'], | 106 | $entry->setTitle($data['title']); |
107 | $data | ||
108 | ); | ||
109 | |||
110 | // jump to next entry in case of problem while getting content | ||
111 | if (false === $entry) { | ||
112 | ++$this->skippedEntries; | ||
113 | 107 | ||
114 | return; | 108 | // update entry with content (in case fetching failed, the given entry will be return) |
115 | } | 109 | $entry = $this->fetchContent($entry, $data['url'], $data); |
116 | 110 | ||
117 | if (array_key_exists('tags', $data)) { | 111 | if (array_key_exists('tags', $data)) { |
118 | $this->contentProxy->assignTagsToEntry( | 112 | $this->contentProxy->assignTagsToEntry( |
diff --git a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php index 48fbbfb6..952521a2 100644 --- a/tests/Wallabag/ImportBundle/Import/PocketImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/PocketImportTest.php | |||
@@ -566,6 +566,8 @@ JSON; | |||
566 | "status": 1, | 566 | "status": 1, |
567 | "list": { | 567 | "list": { |
568 | "229279689": { | 568 | "229279689": { |
569 | "status": "1", | ||
570 | "favorite": "1", | ||
569 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" | 571 | "resolved_url": "http://www.grantland.com/blog/the-triangle/post/_/id/38347/ryder-cup-preview" |
570 | } | 572 | } |
571 | } | 573 | } |
@@ -603,6 +605,6 @@ JSON; | |||
603 | $res = $pocketImport->import(); | 605 | $res = $pocketImport->import(); |
604 | 606 | ||
605 | $this->assertTrue($res); | 607 | $this->assertTrue($res); |
606 | $this->assertEquals(['skipped' => 1, 'imported' => 0, 'queued' => 0], $pocketImport->getSummary()); | 608 | $this->assertEquals(['skipped' => 0, 'imported' => 1, 'queued' => 0], $pocketImport->getSummary()); |
607 | } | 609 | } |
608 | } | 610 | } |
diff --git a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php index b4017f72..12bd6bdd 100644 --- a/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php +++ b/tests/Wallabag/ImportBundle/Import/WallabagV2ImportTest.php | |||
@@ -256,6 +256,6 @@ class WallabagV2ImportTest extends \PHPUnit_Framework_TestCase | |||
256 | $res = $wallabagV2Import->import(); | 256 | $res = $wallabagV2Import->import(); |
257 | 257 | ||
258 | $this->assertTrue($res); | 258 | $this->assertTrue($res); |
259 | $this->assertEquals(['skipped' => 24, 'imported' => 0, 'queued' => 0], $wallabagV2Import->getSummary()); | 259 | $this->assertEquals(['skipped' => 22, 'imported' => 2, 'queued' => 0], $wallabagV2Import->getSummary()); |
260 | } | 260 | } |
261 | } | 261 | } |