diff --git a/src/applications/search/controller/PhabricatorSearchSelectController.php b/src/applications/search/controller/PhabricatorSearchSelectController.php --- a/src/applications/search/controller/PhabricatorSearchSelectController.php +++ b/src/applications/search/controller/PhabricatorSearchSelectController.php @@ -23,31 +23,36 @@ $query->setParameter('query', $query_str); $query->setParameter('types', array($this->type)); + $status_open = PhabricatorSearchRelationship::RELATIONSHIP_OPEN; + switch ($request->getStr('filter')) { case 'assigned': - $query->setParameter('owner', array($user->getPHID())); - $query->setParameter('open', 1); + $query->setParameter('ownerPHIDs', array($user->getPHID())); + $query->setParameter('statuses', array($status_open)); break; case 'created'; - $query->setParameter('author', array($user->getPHID())); + $query->setParameter('authorPHIDs', array($user->getPHID())); // TODO - if / when we allow pholio mocks to be archived, etc // update this if ($this->type != PholioPHIDTypeMock::TYPECONST) { - $query->setParameter('open', 1); + $query->setParameter('statuses', array($status_open)); } break; case 'open': - $query->setParameter('open', 1); + $query->setParameter('statuses', array($status_open)); break; } - $query->setParameter('exclude', $request->getStr('exclude')); - $query->setParameter('limit', 100); + $query->setParameter('excludePHIDs', array($request->getStr('exclude'))); - $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); - $results = $engine->executeSearch($query); + $results = id(new PhabricatorSearchDocumentQuery()) + ->setViewer($user) + ->withSavedQuery($query) + ->setOffset(0) + ->setLimit(100) + ->execute(); - $phids = array_fill_keys($results, true); + $phids = array_fill_keys(mpull($results, 'getPHID'), true); $phids += $this->queryObjectNames($query_str); $phids = array_keys($phids); diff --git a/src/applications/search/query/PhabricatorSearchDocumentQuery.php b/src/applications/search/query/PhabricatorSearchDocumentQuery.php --- a/src/applications/search/query/PhabricatorSearchDocumentQuery.php +++ b/src/applications/search/query/PhabricatorSearchDocumentQuery.php @@ -25,6 +25,19 @@ } protected function willFilterPage(array $handles) { + + // NOTE: This is used by the object selector dialog to exclude the object + // you're looking at, so that, e.g., a task can't be set as a dependency + // of itself in the UI. + + // TODO: Remove this after object selection moves to ApplicationSearch. + + $exclude = array(); + if ($this->savedQuery) { + $exclude_phids = $this->savedQuery->getParameter('excludePHIDs', array()); + $exclude = array_fuse($exclude_phids); + } + foreach ($handles as $key => $handle) { if (!$handle->isComplete()) { unset($handles[$key]); @@ -34,6 +47,10 @@ unset($handles[$key]); continue; } + if (isset($exclude[$handle->getPHID()])) { + unset($handles[$key]); + continue; + } } return $handles;