From 36dd89909cac580a34533d687d8d04058a03c454 Mon Sep 17 00:00:00 2001 From: Javier Lorenzana Date: Sat, 22 Nov 2014 01:09:02 -0300 Subject: [PATCH] Fixing a really nasty bug. --- JsonApi/Request/FilterParser.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/JsonApi/Request/FilterParser.php b/JsonApi/Request/FilterParser.php index 861a7ae..8840c9d 100644 --- a/JsonApi/Request/FilterParser.php +++ b/JsonApi/Request/FilterParser.php @@ -19,6 +19,10 @@ */ class FilterParser { + /** + * @var array + */ + private static $reserved = ['include', 'fields', 'sort', 'page', 'size']; /** * @var MetadataMinerInterface */ @@ -58,8 +62,8 @@ public function parse(Request $request, Params $params) $metadata = $this->metadataMiner->mine($params->primaryClass); $add = function($param, $value, $type) use (&$filters) { $property = Inflector::camelize($param); - $values = explode(',', $value); - $filters[$type][$property] = $values; + if (is_string($value)) $value = explode(',', $value); + $filters[$type][$property] = $value; }; foreach ($request->query as $param => $value) { @@ -67,7 +71,7 @@ public function parse(Request $request, Params $params) $add($param, $value, 'field'); } elseif ($metadata->isRelationship($param)) { $add($param, $value, 'association'); // Doctrine 2 term. - } else { + } elseif (!in_array($param, self::$reserved)) { $add($param, $value, 'custom'); } }