From 349b7b2cdf86ec6a624b21ef6ee175a92c9f296c Mon Sep 17 00:00:00 2001 From: Alessandro Francesconi Date: Fri, 5 Dec 2014 12:01:57 +0100 Subject: [PATCH] Workaround for issue #17 When using "where" clause, array_filter() method outputs a list with some null values in certain situations. The function array_values() can overcome this issue by recreating the indexes. --- src/JamesMoss/Flywheel/Query.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/JamesMoss/Flywheel/Query.php b/src/JamesMoss/Flywheel/Query.php index 5cc146f..7e7527d 100644 --- a/src/JamesMoss/Flywheel/Query.php +++ b/src/JamesMoss/Flywheel/Query.php @@ -89,7 +89,7 @@ public function execute() if ($this->where) { list($field, $operator, $predicate) = $this->where; - $documents = array_filter($documents, function ($doc) use ($field, $operator, $predicate) { + $documents = array_values(array_filter($documents, function ($doc) use ($field, $operator, $predicate) { if (false === strpos($field, '.')) { $value = $doc->{$field}; } else { @@ -121,7 +121,7 @@ public function execute() } return false; - }); + })); } if ($this->orderBy) {