Skip to content
This repository was archived by the owner on Nov 25, 2020. It is now read-only.

Commit d6dd8ca

Browse files
committed
Catch deleteById() exceptions in ElasticSearch
1 parent bfd0372 commit d6dd8ca

File tree

1 file changed

+20
-6
lines changed

1 file changed

+20
-6
lines changed

core/src/plugins/index.elasticsearch/src/ElasticSearchIndexer.php

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ public function applyAction(\Psr\Http\Message\ServerRequestInterface $requestInt
272272
}
273273

274274
if (!file_exists($tmpNode->getUrl())) {
275-
$this->currentType->deleteById($hit->getId());
275+
try{
276+
$this->currentType->deleteById($hit->getId());
277+
}catch (Elastica\Exception\NotFoundException $nfe){}
276278
continue;
277279
}
278280

@@ -333,7 +335,9 @@ public function applyAction(\Psr\Http\Message\ServerRequestInterface $requestInt
333335
$tmpNode->loadNodeInfo();
334336
}
335337
if (!file_exists($tmpNode->getUrl())) {
336-
$this->currentType->deleteById($hit->getId());
338+
try{
339+
$this->currentType->deleteById($hit->getId());
340+
}catch (Elastica\Exception\NotFoundException $eEx){}
337341
continue;
338342
}
339343
$tmpNode->search_score = sprintf("%0.2f", $hit->score);
@@ -392,12 +396,18 @@ public function updateNodeIndexMeta($node)
392396
foreach ($hits as $hit) {
393397
$source = $hit->getSource();
394398
if ($source['ajxp_scope'] == 'shared' || ($source['ajxp_scope'] == 'user' && $source['ajxp_user'] == $node->getContext()->getUser()->getId())) {
395-
$this->currentType->deleteById($hit->getId());
399+
try{
400+
$this->currentType->deleteById($hit->getId());
401+
}catch (Elastica\Exception\NotFoundException $eEx){}
396402
}
397403
}
398404
} else {
399405
$id = $this->getIndexedDocumentId($node);
400-
if($id != null) $this->currentType->deleteById($id);
406+
if($id != null) {
407+
try{
408+
$this->currentType->deleteById($id);
409+
}catch (Elastica\Exception\NotFoundException $eEx){}
410+
}
401411
}
402412
$this->createIndexedDocument($node);
403413

@@ -433,7 +443,9 @@ public function updateNodeIndex($oldNode, $newNode = null, $copy = false, $recur
433443
$childrenHits = $childrenHits->getResults();
434444

435445
foreach ($childrenHits as $hit) {
436-
$this->currentType->deleteById($hit->getId());
446+
try{
447+
$this->currentType->deleteById($hit->getId());
448+
}catch (Elastica\Exception\NotFoundException $eEx){}
437449
}
438450
}
439451
}
@@ -479,7 +491,9 @@ public function updateNodeIndex($oldNode, $newNode = null, $copy = false, $recur
479491
foreach ($childrenHits as $hit) {
480492
$oldChildURL = $this->currentType->getDocument($hit->getId())->get("node_url");
481493
if ($copy == false) {
482-
$this->currentType->deleteById($hit->getId());
494+
try{
495+
$this->currentType->deleteById($hit->getId());
496+
}catch (Elastica\Exception\NotFoundException $eEx){}
483497
}
484498
$newChildURL = str_replace($oldNode->getUrl(),
485499
$newNode->getUrl(),

0 commit comments

Comments
 (0)