diff options
author | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-17 07:40:56 +0200 |
---|---|---|
committer | Jeremy Benoist <jeremy.benoist@gmail.com> | 2016-09-17 07:40:56 +0200 |
commit | 59b97fae996d8307b9d957d210d46200f6d206bf (patch) | |
tree | 9481859d10fafed91067ac7736480e91cd6eb4bb /src/Wallabag/ImportBundle/Import/AbstractImport.php | |
parent | fbb319f064e6336a3b44bda12cdc51c93c51f379 (diff) | |
download | wallabag-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/AbstractImport.php')
-rw-r--r-- | src/Wallabag/ImportBundle/Import/AbstractImport.php | 6 |
1 files changed, 3 insertions, 3 deletions
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 | ||