Skip to content

Commit f83c55e

Browse files
committed
MERGE: Merge branch 'master' into task/debugging-tweaks
2 parents 92bab16 + 2ea9109 commit f83c55e

3 files changed

Lines changed: 28 additions & 20 deletions

File tree

Classes/Driver/AbstractIndexerDriver.php

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ abstract class AbstractIndexerDriver extends AbstractDriver
2222
* Whether the node is configured as fulltext root.
2323
*
2424
* @param NodeInterface $node
25-
* @return boolean
25+
* @return bool
2626
*/
27-
protected function isFulltextRoot(NodeInterface $node)
27+
protected function isFulltextRoot(NodeInterface $node): bool
2828
{
2929
if ($node->getNodeType()->hasConfiguration('search')) {
3030
$elasticSearchSettingsForNode = $node->getNodeType()->getConfiguration('search');
@@ -35,4 +35,24 @@ protected function isFulltextRoot(NodeInterface $node)
3535

3636
return false;
3737
}
38+
39+
/**
40+
* @param NodeInterface $node
41+
* @return NodeInterface|null
42+
*/
43+
protected function findClosestFulltextRoot(NodeInterface $node)
44+
{
45+
$closestFulltextNode = $node;
46+
while (!$this->isFulltextRoot($closestFulltextNode)) {
47+
$closestFulltextNode = $closestFulltextNode->getParent();
48+
if ($closestFulltextNode === null) {
49+
// root of hierarchy, no fulltext root found anymore, abort silently...
50+
$this->logger->log(sprintf('NodeIndexer: No fulltext root found for node %s (%s)', $node->getContextPath(), $node->getIdentifier()), LOG_WARNING, null, 'ElasticSearch (CR)');
51+
52+
return null;
53+
}
54+
}
55+
56+
return $closestFulltextNode;
57+
}
3858
}

Classes/Driver/Version1/IndexerDriver.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,9 @@ public function document($indexName, NodeInterface $node, ElasticSearchDocument
7676
*/
7777
public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, $targetWorkspaceName = null)
7878
{
79-
$closestFulltextNode = $node;
80-
while (!$this->isFulltextRoot($closestFulltextNode)) {
81-
$closestFulltextNode = $closestFulltextNode->getParent();
82-
if ($closestFulltextNode === null) {
83-
// root of hierarchy, no fulltext root found anymore, abort silently...
84-
$this->logger->log(sprintf('NodeIndexer: No fulltext root found for node %s (%s)', $node->getPath(), $node->getIdentifier()), LOG_WARNING, null, 'ElasticSearch (CR)');
85-
86-
return null;
87-
}
79+
$closestFulltextNode = $this->findClosestFulltextRoot($node);
80+
if ($closestFulltextNode === null) {
81+
return null;
8882
}
8983

9084
$closestFulltextNodeContextPath = $closestFulltextNode->getContextPath();

Classes/Driver/Version2/IndexerDriver.php

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,9 @@ public function document($indexName, NodeInterface $node, ElasticSearchDocument
7979
*/
8080
public function fulltext(NodeInterface $node, array $fulltextIndexOfNode, $targetWorkspaceName = null)
8181
{
82-
$closestFulltextNode = $node;
83-
while (!$this->isFulltextRoot($closestFulltextNode)) {
84-
$closestFulltextNode = $closestFulltextNode->getParent();
85-
if ($closestFulltextNode === null) {
86-
// root of hierarchy, no fulltext root found anymore, abort silently...
87-
$this->logger->log(sprintf('NodeIndexer: No fulltext root found for node %s (%s)', $node->getContextPath(), $node->getIdentifier()), LOG_WARNING, null, 'ElasticSearch (CR)');
88-
89-
return null;
90-
}
82+
$closestFulltextNode = $this->findClosestFulltextRoot($node);
83+
if ($closestFulltextNode === null) {
84+
return null;
9185
}
9286

9387
$closestFulltextNodeContextPath = $closestFulltextNode->getContextPath();

0 commit comments

Comments
 (0)