Skip to content

Commit 602d8ba

Browse files
authored
Bugfix: Asset Numeric IN Filtering (#1020)
* If numeric check to see if filter operator is in, and try and parse value if not array. * Re-arrange logic.
1 parent 9b706e9 commit 602d8ba

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/Helper/GridHelperService.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,6 +838,18 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M
838838
$operator = '>';
839839
} elseif ($filterOperator == 'eq') {
840840
$operator = '=';
841+
} elseif ($filterOperator == 'in') {
842+
$operator = 'IN';
843+
844+
$filterValue = $filter['value'] ?? '';
845+
if (!is_array($filterValue)) {
846+
$matches = preg_split('/[^0-9\.]+/', $filterValue, -1, PREG_SPLIT_NO_EMPTY);
847+
if (is_array($matches) && count($matches) > 0) {
848+
$filter['value'] = array_unique(array_map(floatval(...), $matches));
849+
} else {
850+
continue;
851+
}
852+
}
841853
}
842854
} elseif ($filterType == 'date') {
843855
$filter['value'] = strtotime($filter['value']);
@@ -866,8 +878,9 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M
866878
if (empty($value)) {
867879
continue;
868880
}
881+
869882
$quoted = array_map(function ($val) use ($db) {
870-
return $db->quote($val);
883+
return $db->quote((string)$val);
871884
}, $value);
872885
$value = '(' . implode(',', $quoted) . ')';
873886
} elseif ($operator == 'BETWEEN') {

0 commit comments

Comments
 (0)