From 76af4d649bfcc8a6cfd6ca494c52f4be799dab9c Mon Sep 17 00:00:00 2001 From: epriestley Date: Wed, 7 Sep 2016 07:36:12 -0700 Subject: [PATCH] Fix ContainsConstraints for array-valued custom field constraints in "*.search" methods Summary: Fixes T11593. We ask for a list of values when searching for custom "link" fields, but don't handle it correctly when actually construcitng a query. Test Plan: Added this custom field: ``` { "mycompany.target-version": { "name": "Target Version", "type": "link", "search": true } } ``` Set a task to "beta". Let daemons index it. Queried for: ``` constraints: { "custom.mycompany.target-version": [ "beta" ] } ``` Got just one result back. Reviewers: chad Reviewed By: chad Maniphest Tasks: T11593 Differential Revision: https://secure.phabricator.com/D16508 --- .../standard/PhabricatorStandardCustomFieldLink.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php index 66f3605b9c..c2b9d6543c 100644 --- a/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php +++ b/src/infrastructure/customfield/standard/PhabricatorStandardCustomFieldLink.php @@ -47,7 +47,12 @@ final class PhabricatorStandardCustomFieldLink PhabricatorCursorPagedPolicyAwareQuery $query, $value) { - if (strlen($value)) { + if (is_string($value) && !strlen($value)) { + return; + } + + $value = (array)$value; + if ($value) { $query->withApplicationSearchContainsConstraint( $this->newStringIndex(null), $value);