partkeepr

fork of partkeepr
git clone https://git.e1e0.net/partkeepr.git
Log | Files | Refs | Submodules | README | LICENSE

commit 03f4b35c8a50a15125280998e6cb83d6c012d155
parent 8a2674853bf97bca411d08e1974c2d7a245233dd
Author: Felicitus <felicitus@felicitus.org>
Date:   Fri,  2 Oct 2015 18:42:48 +0200

Check if the property exists via propery_exists and not by accessing the member directly. This fixes the issue where one could pass value:0 and would cause the exception to throw.

Diffstat:
Msrc/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php b/src/PartKeepr/DoctrineReflectionBundle/Filter/AdvancedSearchFilter.php @@ -349,7 +349,7 @@ class AdvancedSearchFilter extends AbstractFilter { $filter = array(); - if ($data->property) { + if (property_exists($data, "property")) { if (strpos($data->property, ".") !== false) { $associations = explode(".", $data->property); @@ -366,7 +366,7 @@ class AdvancedSearchFilter extends AbstractFilter throw new \Exception("You need to set the filter property"); } - if ($data->operator) { + if (property_exists($data, "operator")) { if (!in_array(strtolower($data->operator), self::OPERATORS)) { throw new \Exception(sprintf("Invalid operator %s", $data->operator)); } @@ -375,7 +375,7 @@ class AdvancedSearchFilter extends AbstractFilter $filter["operator"] = self::OPERATOR_EQUALS; } - if ($data->value) { + if (property_exists($data, "value")) { $filter["value"] = $data->value; } else { throw new \Exception("No value specified");