Skip to content

Commit 9e9752d

Browse files
committed
Merge pull request #113 from Flowpack/bugfix-index-dimensions
[BUGFIX] Fix indexing without dimension or with custom dimensions
2 parents 421eb9a + 041b556 commit 9e9752d

1 file changed

Lines changed: 17 additions & 15 deletions

File tree

  • Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer

Classes/Flowpack/ElasticSearch/ContentRepositoryAdaptor/Indexer/NodeIndexer.php

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Flowpack\ElasticSearch\Domain\Model\Client;
1717
use Flowpack\ElasticSearch\Domain\Model\Document as ElasticSearchDocument;
1818
use Flowpack\ElasticSearch\Domain\Model\Index;
19-
use TYPO3\Eel\FlowQuery\FlowQuery;
2019
use TYPO3\Flow\Annotations as Flow;
2120
use TYPO3\TYPO3CR\Domain\Model\NodeInterface;
2221
use TYPO3\TYPO3CR\Domain\Service\ContentDimensionCombinator;
@@ -259,22 +258,25 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null)
259258
$this->logger->log(sprintf('NodeIndexer: Added / updated node %s. ID: %s Context: %s', $contextPath, $contextPathHash, json_encode($node->getContext()->getProperties())), LOG_DEBUG, null, 'ElasticSearch (CR)');
260259
};
261260

262-
$combinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
263-
$contextProperties = $node->getContext()->getProperties();
264-
foreach ($combinations as $combination) {
265-
$dimensions = array_merge($contextProperties['dimensions'], $combination);
266-
$targetDimensions = array_merge($contextProperties['targetDimensions'], [ 'language' => $combination['language'][0] ]);
267-
$query = new FlowQuery([$node]);
268-
$query->pushOperation('context', [[
269-
'dimensions' => $dimensions,
270-
'targetDimensions' => $targetDimensions
271-
]]);
272-
/** @var NodeInterface $indexableNode */
273-
$indexableNode = $query->get(0);
274-
if ($indexableNode instanceof NodeInterface) {
275-
$indexer($indexableNode, $targetWorkspaceName);
261+
$dimensionCombinations = $this->contentDimensionCombinator->getAllAllowedCombinations();
262+
$workspaceName = $targetWorkspaceName ?: 'live';
263+
$nodeIdentifier = $node->getIdentifier();
264+
if ($dimensionCombinations !== []) {
265+
foreach ($dimensionCombinations as $combination) {
266+
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName, 'dimensions' => $combination));
267+
$node = $context->getNodeByIdentifier($nodeIdentifier);
268+
if ($node !== null) {
269+
$indexer($node, $targetWorkspaceName);
270+
}
271+
}
272+
} else {
273+
$context = $this->contextFactory->create(array('workspaceName' => $workspaceName));
274+
$node = $context->getNodeByIdentifier($nodeIdentifier);
275+
if ($node !== NULL) {
276+
$indexer($node, $targetWorkspaceName);
276277
}
277278
}
279+
278280
}
279281

280282
/**

0 commit comments

Comments
 (0)