Skip to content

Commit c07916c

Browse files
remuslazardaniellienert
authored andcommitted
Fix a caching issue in indexNode()
This fixes a weird issue when the node instance from context does not have the right path. See inline comments for details.
1 parent a1df0d6 commit c07916c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Classes/Indexer/NodeIndexer.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,13 @@ public function indexNode(NodeInterface $node, $targetWorkspaceName = null): voi
274274
$handleNode = function (NodeInterface $node, Context $context) use ($targetWorkspaceName, $indexer) {
275275
$nodeFromContext = $context->getNodeByIdentifier($node->getIdentifier());
276276
if ($nodeFromContext instanceof NodeInterface) {
277+
if ($node->getPath() !== $nodeFromContext->getPath()) {
278+
// If the node from context does have a different path, purge the context cache and re-fetch
279+
280+
// TODO: find a better way to handle this
281+
$context->getFirstLevelNodeCache()->flush();
282+
$nodeFromContext = $context->getNodeByIdentifier($node->getIdentifier());
283+
}
277284
$this->searchClient->withDimensions(static function () use ($indexer, $nodeFromContext, $targetWorkspaceName) {
278285
$indexer($nodeFromContext, $targetWorkspaceName);
279286
}, $nodeFromContext->getContext()->getTargetDimensions());

0 commit comments

Comments
 (0)