From 1e3d74a9cfdaf708632a97660e1811dd819f7df4 Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 21:17:03 +0200 Subject: Avoid RabbitMQ consumer to loop When the `parseEntry` returns null it means the entry already exists in the database. Sending `false` as return, will requeue the message which will then loop forever. --- src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/Wallabag/ImportBundle') diff --git a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php index 2b85ad76..b893ea29 100644 --- a/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php +++ b/src/Wallabag/ImportBundle/Consumer/AbstractConsumer.php @@ -50,9 +50,10 @@ abstract class AbstractConsumer $entry = $this->import->parseEntry($storedEntry); if (null === $entry) { - $this->logger->warning('Unable to parse entry', ['entry' => $storedEntry]); + $this->logger->warning('Entry already exists', ['entry' => $storedEntry]); - return false; + // return true to skip message + return true; } try { -- cgit v1.2.3 From 54535004587693952f4aef5ee5798298f4cda7fa Mon Sep 17 00:00:00 2001 From: Jeremy Benoist Date: Thu, 20 Oct 2016 21:17:45 +0200 Subject: Requeue depending on producer Browser import can requeue message from `parseEntry` but we should take care of the way import are handled (depending on the producer) --- src/Wallabag/ImportBundle/Import/BrowserImport.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/Wallabag/ImportBundle') diff --git a/src/Wallabag/ImportBundle/Import/BrowserImport.php b/src/Wallabag/ImportBundle/Import/BrowserImport.php index 9d75685b..2ca1683b 100644 --- a/src/Wallabag/ImportBundle/Import/BrowserImport.php +++ b/src/Wallabag/ImportBundle/Import/BrowserImport.php @@ -139,12 +139,24 @@ abstract class BrowserImport extends AbstractImport public function parseEntry(array $importedEntry) { if ((!array_key_exists('guid', $importedEntry) || (!array_key_exists('id', $importedEntry))) && is_array(reset($importedEntry))) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry); + + return; + } + $this->parseEntries($importedEntry); return; } if (array_key_exists('children', $importedEntry)) { + if ($this->producer) { + $this->parseEntriesForProducer($importedEntry['children']); + + return; + } + $this->parseEntries($importedEntry['children']); return; -- cgit v1.2.3