Premising that you can already "easily" find objects by a custom field __single__ value - see Q117;
It seems that you cannot do an "IN" query with multiple values.
So, this works to find objects with a value:
```lang=php
$field_key = 'std:maniphest:custom-list.hours';
// This works
$query_value = '222';
// Un-comment to cause a nuclear crash
// $query_value = array( '221', '222', '223' );
// Find the Field definition
$engine = new ManiphestTaskSearchEngine();
$task = new ManiphestTask();
$field = PhabricatorCustomField::getObjectField(
$task,
PhabricatorCustomField::ROLE_DEFAULT,
$field_key);
$query = ($engine->newQuery())
->setViewer($viewer);
$field->applyApplicationSearchConstraintToQuery(
$engine,
$query,
$query_value);
$results = $query->execute();
foreach( $results as $res ) {
echo(pht("Found task with id: %d \n", $res->getID()));
}
```
With multiple values I get this exception:
```counterexample
[2024-03-07 12:13:47] EXCEPTION: (InvalidArgumentException) Call to phutil_nonempty_scalar() expected: a string; or stringlike object; or int; or float. Got: list<string>. at [<arcanist>/src/utils/utils.php:2230]
#0 phutil_nonempty_scalar(array) called at [<phorge>/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php:56]
...
```
Maybe I'm doing it wrong, but anyway, that exception is raised here:
https://we.phorge.it/source/phorge/browse/master/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php;faf43d7edf7b2da743cc900e4ecdca10f64a973f$51-61
Previous version also affected:
https://we.phorge.it/source/phorge/browse/master/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php;821708414eecc90824810f7805cf236da3124498$51-61
---
But interestingly, under the hood, this thing is already supported:
https://we.phorge.it/source/phorge/browse/master/src/infrastructure/query/policy/PhabricatorCursorPagedPolicyAwareQuery.php;faf43d7edf7b2da743cc900e4ecdca10f64a973f$1344-1358
== Proposed solution ==
I was able to make this working with this local patch, but
```diff
diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php
index 3ee42a531c..e7b42f002f 100644
--- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php
+++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldInt.php
@@ -53,7 +53,13 @@ final class PhabricatorStandardCustomFieldInt
PhabricatorCursorPagedPolicyAwareQuery $query,
$value) {
- if (phutil_nonempty_scalar($value)) {
+ if(is_array($value)) {
+ $is_nonempty = $value;
+ } else {
+ $is_nonempty = phutil_nonempty_scalar($value);
+ }
+
+ if ($is_nonempty) {
$query->withApplicationSearchContainsConstraint(
$this->newNumericIndex(null),
$value);
```