Skip to content

Commit

Permalink
Use non-strict comparison in FilterByReferenceOperation (#37)
Browse files Browse the repository at this point in the history
It is comparing Node instances, and those are not the same… that leads
to the comparison failing, even though they are semantically equal.

The "proper" way would be to check by some custom method (e.g. an
`equals()` method on `Node`), but going back to non-strict comparison
here is fine.

Note: Not just removing the `true` on `is_array()` to clarify the intention.
Taken from #36 and amended.
  • Loading branch information
kdambekalns authored and dimaip committed Oct 4, 2019
1 parent 1d50fb0 commit 3a55eb6
Showing 1 changed file with 1 addition and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function evaluate(FlowQuery $flowQuery, array $arguments)
foreach ($flowQuery->getContext() as $node) {
/** @var NodeInterface $node */
$propertyValue = $node->getProperty($filterByPropertyPath);
if ($nodeReference === $propertyValue || (is_array($propertyValue) && in_array($nodeReference, $propertyValue, true))) {
if ($nodeReference == $propertyValue || (is_array($propertyValue) && in_array($nodeReference, $propertyValue, false))) {
$filteredNodes[] = $node;
}
}
Expand Down

0 comments on commit 3a55eb6

Please sign in to comment.