diff --git a/Civi/Api4/Generic/Traits/ArrayQueryActionTrait.php b/Civi/Api4/Generic/Traits/ArrayQueryActionTrait.php index fd515b9a4b71..f393739fc2a7 100644 --- a/Civi/Api4/Generic/Traits/ArrayQueryActionTrait.php +++ b/Civi/Api4/Generic/Traits/ArrayQueryActionTrait.php @@ -94,7 +94,7 @@ private function walkFilters($row, $filters) { return $result; default: - return $this->filterCompare($row, $filters); + return self::filterCompare($row, $filters); } } @@ -104,7 +104,7 @@ private function walkFilters($row, $filters) { * @return bool * @throws \Civi\API\Exception\NotImplementedException */ - private function filterCompare($row, $condition) { + public static function filterCompare($row, $condition) { if (!is_array($condition)) { throw new NotImplementedException('Unexpected where syntax; expecting array.'); } diff --git a/api/v3/utils.php b/api/v3/utils.php index f0db7003173a..95507f60133f 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -2478,6 +2478,17 @@ function _civicrm_api3_basic_array_get($entity, $params, $records, $idCol, $filt $matches = []; + $isMatch = function($record, $key, $searchValue) { + if (is_array($searchValue) && count($searchValue) === 1 && in_array(array_keys($searchValue)[0], CRM_Core_DAO::acceptedSQLOperators())) { + $operator = array_keys($searchValue)[0]; + $searchValue = array_values($searchValue)[0]; + return \Civi\Api4\Generic\Traits\ArrayQueryActionTrait::filterCompare($record, [$key, $operator, $searchValue]); + } + // Prior to supporting multiple search operators this function used the sloppy == comparison + // So for backward compatibility we'll continue to use it when no operator is explicitly given + return $searchValue == ($record[$key] ?? NULL); + }; + $currentOffset = 0; foreach ($records as $record) { if ($idCol != 'id') { @@ -2488,7 +2499,7 @@ function _civicrm_api3_basic_array_get($entity, $params, $records, $idCol, $filt if ($k == 'id') { $k = $idCol; } - if (in_array($k, $filterableFields) && $record[$k] != $v) { + if (in_array($k, $filterableFields) && !$isMatch($record, $k, $v)) { $match = FALSE; break; } diff --git a/ext/afform/core/afform.php b/ext/afform/core/afform.php index 934f62f0787c..b78dae8acced 100644 --- a/ext/afform/core/afform.php +++ b/ext/afform/core/afform.php @@ -415,7 +415,9 @@ function afform_civicrm_preProcess($formName, &$form) { 'key' => 'name', 'entity' => 'Afform', 'select' => ['minimumInputLength' => 0], - 'api' => [], + 'api' => [ + 'params' => ['type' => ['IN' => ['form', 'search']]], + ], ], ]; }