Skip to content

Commit 16437c6

Browse files
torqdevkingjia90
authored andcommitted
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. (cherry picked from commit 602d8ba)
1 parent f37e4b1 commit 16437c6

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
@@ -820,6 +820,18 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M
820820
$operator = '>';
821821
} elseif ($filterOperator == 'eq') {
822822
$operator = '=';
823+
} elseif ($filterOperator == 'in') {
824+
$operator = 'IN';
825+
826+
$filterValue = $filter['value'] ?? '';
827+
if (!is_array($filterValue)) {
828+
$matches = preg_split('/[^0-9\.]+/', $filterValue, -1, PREG_SPLIT_NO_EMPTY);
829+
if (is_array($matches) && count($matches) > 0) {
830+
$filter['value'] = array_unique(array_map(floatval(...), $matches));
831+
} else {
832+
continue;
833+
}
834+
}
823835
}
824836
} elseif ($filterType == 'date') {
825837
$filter['value'] = strtotime($filter['value']);
@@ -850,8 +862,9 @@ public function prepareAssetListingForGrid(array $allParams, User $adminUser): M
850862
if (empty($value)) {
851863
continue;
852864
}
865+
853866
$quoted = array_map(function ($val) use ($db) {
854-
return $db->quote($val);
867+
return $db->quote((string)$val);
855868
}, $value);
856869
$value = '(' . implode(',', $quoted) . ')';
857870
} elseif ($operator == 'BETWEEN') {

0 commit comments

Comments
 (0)