Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2891947
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
5 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/src/applications/search/controller/PhabricatorSearchSelectController.php b/src/applications/search/controller/PhabricatorSearchSelectController.php
index 9a6623f66f..e9e62e0393 100644
--- a/src/applications/search/controller/PhabricatorSearchSelectController.php
+++ b/src/applications/search/controller/PhabricatorSearchSelectController.php
@@ -1,77 +1,82 @@
<?php
/**
* @group search
*/
final class PhabricatorSearchSelectController
extends PhabricatorSearchBaseController {
private $type;
public function willProcessRequest(array $data) {
$this->type = $data['type'];
}
public function processRequest() {
$request = $this->getRequest();
$user = $request->getUser();
$query = new PhabricatorSavedQuery();
$query_str = $request->getStr('query');
$query->setEngineClassName('PhabricatorSearchApplicationSearchEngine');
$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);
$handles = $this->loadViewerHandles($phids);
$data = array();
foreach ($handles as $handle) {
$view = new PhabricatorHandleObjectSelectorDataView($handle);
$data[] = $view->renderData();
}
return id(new AphrontAjaxResponse())->setContent($data);
}
private function queryObjectNames($query) {
$viewer = $this->getRequest()->getUser();
$objects = id(new PhabricatorObjectQuery())
->setViewer($viewer)
->withTypes(array($this->type))
->withNames(array($query))
->execute();
return mpull($objects, 'getPHID');
}
}
diff --git a/src/applications/search/query/PhabricatorSearchDocumentQuery.php b/src/applications/search/query/PhabricatorSearchDocumentQuery.php
index 92a2ec36ba..bec7cd76fd 100644
--- a/src/applications/search/query/PhabricatorSearchDocumentQuery.php
+++ b/src/applications/search/query/PhabricatorSearchDocumentQuery.php
@@ -1,68 +1,85 @@
<?php
final class PhabricatorSearchDocumentQuery
extends PhabricatorCursorPagedPolicyAwareQuery {
private $savedQuery;
public function withSavedQuery(PhabricatorSavedQuery $query) {
$this->savedQuery = $query;
return $this;
}
protected function loadPage() {
$phids = $this->loadDocumentPHIDsWithoutPolicyChecks();
$handles = id(new PhabricatorHandleQuery())
->setViewer($this->getViewer())
->withPHIDs($phids)
->execute();
// Retain engine order.
$handles = array_select_keys($handles, $phids);
return $handles;
}
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]);
continue;
}
if ($handle->getPolicyFiltered()) {
unset($handles[$key]);
continue;
}
+ if (isset($exclude[$handle->getPHID()])) {
+ unset($handles[$key]);
+ continue;
+ }
}
return $handles;
}
public function loadDocumentPHIDsWithoutPolicyChecks() {
$query = id(clone($this->savedQuery))
->setParameter('offset', $this->getOffset())
->setParameter('limit', $this->getRawResultLimit());
$engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
return $engine->executeSearch($query);
}
public function getQueryApplicationClass() {
return 'PhabricatorApplicationSearch';
}
protected function getPagingValue($result) {
throw new Exception(
pht(
'This query does not support cursor paging; it must be offset '.
'paged.'));
}
protected function nextPage(array $page) {
$this->setOffset($this->getOffset() + count($page));
return $this;
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sun, Jan 19, 15:59 (2 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1126258
Default Alt Text
(5 KB)
Attached To
Mode
rP Phorge
Attached
Detach File
Event Timeline
Log In to Comment