aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/ImportBundle/Import/AbstractImport.php
diff options
context:
space:
mode:
authorJeremy Benoist <jeremy.benoist@gmail.com>2018-12-18 13:14:42 +0100
committerJeremy Benoist <jeremy.benoist@gmail.com>2019-01-03 09:42:06 +0100
commit9f8f188d928b47503d39348c5990379a572b570a (patch)
tree0e2b7e488312b7bcb51efee8979ff35544997716 /src/Wallabag/ImportBundle/Import/AbstractImport.php
parent4d0c632c70ea50d459c3c55ddda2e0f394dd51cb (diff)
downloadwallabag-9f8f188d928b47503d39348c5990379a572b570a.tar.gz
wallabag-9f8f188d928b47503d39348c5990379a572b570a.tar.zst
wallabag-9f8f188d928b47503d39348c5990379a572b570a.zip
Validate imported entry to avoid error on import
We got some imports with a missing `url` field generating some errors while trying to retrieve an existing entry with that url. Introducing the `validateEntry` allow us to dismiss a message when it doesn't have an url (or other missing stuff in the future)
Diffstat (limited to 'src/Wallabag/ImportBundle/Import/AbstractImport.php')
-rw-r--r--src/Wallabag/ImportBundle/Import/AbstractImport.php17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/Wallabag/ImportBundle/Import/AbstractImport.php b/src/Wallabag/ImportBundle/Import/AbstractImport.php
index 58a234f4..d39d71b6 100644
--- a/src/Wallabag/ImportBundle/Import/AbstractImport.php
+++ b/src/Wallabag/ImportBundle/Import/AbstractImport.php
@@ -119,6 +119,15 @@ abstract class AbstractImport implements ImportInterface
119 abstract public function parseEntry(array $importedEntry); 119 abstract public function parseEntry(array $importedEntry);
120 120
121 /** 121 /**
122 * Validate that an entry is valid (like has some required keys, etc.).
123 *
124 * @param array $importedEntry
125 *
126 * @return bool
127 */
128 abstract public function validateEntry(array $importedEntry);
129
130 /**
122 * Fetch content from the ContentProxy (using graby). 131 * Fetch content from the ContentProxy (using graby).
123 * If it fails return the given entry to be saved in all case (to avoid user to loose the content). 132 * If it fails return the given entry to be saved in all case (to avoid user to loose the content).
124 * 133 *
@@ -141,9 +150,9 @@ abstract class AbstractImport implements ImportInterface
141 /** 150 /**
142 * Parse and insert all given entries. 151 * Parse and insert all given entries.
143 * 152 *
144 * @param $entries 153 * @param array $entries
145 */ 154 */
146 protected function parseEntries($entries) 155 protected function parseEntries(array $entries)
147 { 156 {
148 $i = 1; 157 $i = 1;
149 $entryToBeFlushed = []; 158 $entryToBeFlushed = [];
@@ -153,6 +162,10 @@ abstract class AbstractImport implements ImportInterface
153 $importedEntry = $this->setEntryAsRead($importedEntry); 162 $importedEntry = $this->setEntryAsRead($importedEntry);
154 } 163 }
155 164
165 if (false === $this->validateEntry($importedEntry)) {
166 continue;
167 }
168
156 $entry = $this->parseEntry($importedEntry); 169 $entry = $this->parseEntry($importedEntry);
157 170
158 if (null === $entry) { 171 if (null === $entry) {