Silently ignore invalid (already deleted) pastes
authorChristian Weiske <cweiske@cweiske.de>
Wed, 19 Apr 2017 16:21:03 +0000 (18:21 +0200)
committerChristian Weiske <cweiske@cweiske.de>
Wed, 19 Apr 2017 16:21:03 +0000 (18:21 +0200)
ElasticSearch takes a bit to delete a paste, and we got exceptions
when trying to list recent pastes when one of them had been deleted.

Resolves: https://github.com/cweiske/phorkie/issues/25

src/phorkie/Database/Adapter/Elasticsearch/Search.php

index ddbc13b..cc3941a 100644 (file)
@@ -64,7 +64,11 @@ class Database_Adapter_Elasticsearch_Search implements Database_ISearch
 
         foreach ($jRes->hits->hits as $hit) {
             $r = new Repository();
-            $r->loadById($hit->_source->id);
+            try {
+                $r->loadById($hit->_source->id);
+            } catch (Exception_NotFound $e) {
+                continue;
+            }
             $r->crdate = strtotime($hit->_source->crdate);
             $r->modate = strtotime($hit->_source->modate);
             $sres->repos[] = $r;