Skip to content

Commit

Permalink
BUGFIX: Unable to search nodes with multiple terms (#2143)
Browse files Browse the repository at this point in the history
This change fix a regression introduced by 8667795

The method NodeSearchService::findByProperties must accept term as
string or array. Currently the array support is broken.
  • Loading branch information
dfeyer authored and daniellienert committed Aug 15, 2018
1 parent 4edb291 commit 9250ff0
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Classes/Domain/Service/NodeSearchService.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,20 @@ public function findByProperties($term, array $searchNodeTypes, Context $context
throw new \InvalidArgumentException('"term" cannot be empty: provide a term to search for.', 1421329285);
}

$searchResult = array();
$searchResult = [];
$nodeTypeFilter = implode(',', $searchNodeTypes);

if (preg_match(NodeIdentifierValidator::PATTERN_MATCH_NODE_IDENTIFIER, $term) !== 0) {
$nodeByIdentifier = $context->getNodeByIdentifier($term);
if ($nodeByIdentifier !== null && $this->nodeSatisfiesSearchNodeTypes($nodeByIdentifier, $searchNodeTypes)) {
$searchResult[$nodeByIdentifier->getPath()] = $nodeByIdentifier;
$searchTerm = is_string($term) ? [$term] : $term;

foreach ($searchTerm as $term) {
if (preg_match(NodeIdentifierValidator::PATTERN_MATCH_NODE_IDENTIFIER, $term) !== 0) {
$nodeByIdentifier = $context->getNodeByIdentifier($term);
if ($nodeByIdentifier !== null && $this->nodeSatisfiesSearchNodeTypes($nodeByIdentifier, $searchNodeTypes)) {
$searchResult[$nodeByIdentifier->getPath()] = $nodeByIdentifier;
}
}
}

$nodeDataRecords = $this->nodeDataRepository->findByProperties($term, $nodeTypeFilter, $context->getWorkspace(), $context->getDimensions(), $startingPoint ? $startingPoint->getPath() : null);
foreach ($nodeDataRecords as $nodeData) {
$node = $this->nodeFactory->createFromNodeData($nodeData, $context);
Expand Down

0 comments on commit 9250ff0

Please sign in to comment.