diff --git a/src/applications/base/controller/PhabricatorController.php b/src/applications/base/controller/PhabricatorController.php
index e7ae1d0f8d..e015f3a67f 100644
--- a/src/applications/base/controller/PhabricatorController.php
+++ b/src/applications/base/controller/PhabricatorController.php
@@ -225,6 +225,10 @@ abstract class PhabricatorController extends AphrontController {
return $this;
}
+ protected function getLoadedHandles() {
+ return $this->handles;
+ }
+
protected function loadViewerHandles(array $phids) {
return id(new PhabricatorObjectHandleData($phids))
->setViewer($this->getRequest()->getUser())
diff --git a/src/applications/ponder/controller/PonderQuestionViewController.php b/src/applications/ponder/controller/PonderQuestionViewController.php
index 47a0d08599..4a34a328f0 100644
--- a/src/applications/ponder/controller/PonderQuestionViewController.php
+++ b/src/applications/ponder/controller/PonderQuestionViewController.php
@@ -41,8 +41,8 @@ final class PonderQuestionViewController extends PonderController {
$object_phids = array_merge($object_phids, $subscribers);
- $handles = $this->loadViewerHandles($object_phids);
$this->loadHandles($object_phids);
+ $handles = $this->getLoadedHandles();
$detail_panel = new PonderQuestionDetailView();
$detail_panel
diff --git a/src/applications/ponder/search/PhabricatorSearchPonderIndexer.php b/src/applications/ponder/search/PhabricatorSearchPonderIndexer.php
index d2dcdefbc0..755b4f4b35 100644
--- a/src/applications/ponder/search/PhabricatorSearchPonderIndexer.php
+++ b/src/applications/ponder/search/PhabricatorSearchPonderIndexer.php
@@ -48,6 +48,19 @@ final class PhabricatorSearchPonderIndexer
}
}
+ $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID(
+ $question->getPHID());
+ $handles = id(new PhabricatorObjectHandleData($subscribers))
+ ->loadHandles();
+
+ foreach ($handles as $phid => $handle) {
+ $doc->addRelationship(
+ PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,
+ $phid,
+ $handle->getType(),
+ $question->getDateModified()); // Bogus timestamp.
+ }
+
self::reindexAbstractDocument($doc);
}
}
diff --git a/src/applications/search/controller/PhabricatorSearchController.php b/src/applications/search/controller/PhabricatorSearchController.php
index e0e61cafaa..4ffe4798aa 100644
--- a/src/applications/search/controller/PhabricatorSearchController.php
+++ b/src/applications/search/controller/PhabricatorSearchController.php
@@ -81,6 +81,11 @@ final class PhabricatorSearchController
$query->setParameter('owner', $request->getArr('owner'));
}
+ if ($request->getArr('subscribers')) {
+ $query->setParameter('subscribers',
+ $request->getArr('subscribers'));
+ }
+
if ($request->getInt('open')) {
$query->setParameter('open', $request->getInt('open'));
}
@@ -109,6 +114,7 @@ final class PhabricatorSearchController
$phids = array_merge(
$query->getParameter('author', array()),
$query->getParameter('owner', array()),
+ $query->getParameter('subscribers', array()),
$query->getParameter('project', array())
);
@@ -124,6 +130,11 @@ final class PhabricatorSearchController
$query->getParameter('owner', array()));
$owner_value = mpull($owner_value, 'getFullName', 'getPHID');
+ $subscribers_value = array_select_keys(
+ $handles,
+ $query->getParameter('subscribers', array()));
+ $subscribers_value = mpull($subscribers_value, 'getFullName', 'getPHID');
+
$project_value = array_select_keys(
$handles,
$query->getParameter('project', array()));
@@ -172,6 +183,12 @@ final class PhabricatorSearchController
->setValue($owner_value)
->setCaption(
'Tip: search for "Up For Grabs" to find unowned documents.'))
+ ->appendChild(
+ id(new AphrontFormTokenizerControl())
+ ->setName('subscribers')
+ ->setLabel('Subscribers')
+ ->setDatasource('/typeahead/common/users/')
+ ->setValue($subscribers_value))
->appendChild(
id(new AphrontFormTokenizerControl())
->setName('project')
@@ -213,15 +230,16 @@ final class PhabricatorSearchController
if ($results) {
- $loader = new PhabricatorObjectHandleData($results);
+ $loader = id(new PhabricatorObjectHandleData($results))
+ ->setViewer($user);
$handles = $loader->loadHandles();
$objects = $loader->loadObjects();
$results = array();
foreach ($handles as $phid => $handle) {
- $view = new PhabricatorSearchResultView();
- $view->setHandle($handle);
- $view->setQuery($query);
- $view->setObject(idx($objects, $phid));
+ $view = id(new PhabricatorSearchResultView())
+ ->setHandle($handle)
+ ->setQuery($query)
+ ->setObject(idx($objects, $phid));
$results[] = $view->render();
}
$results =
diff --git a/src/applications/search/controller/PhabricatorSearchIndexController.php b/src/applications/search/controller/PhabricatorSearchIndexController.php
deleted file mode 100644
index c73928cb65..0000000000
--- a/src/applications/search/controller/PhabricatorSearchIndexController.php
+++ /dev/null
@@ -1,129 +0,0 @@
-phid = $data['phid'];
- }
-
- public function processRequest() {
-
- $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine();
- $document = $engine->reconstructDocument($this->phid);
- if (!$document) {
- return new Aphront404Response();
- }
-
- $panels = array();
-
- $panel = new AphrontPanelView();
- $panel->setHeader('Abstract Document Index');
-
- $props = array(
- 'PHID' => phutil_escape_html($document->getPHID()),
- 'Title' => phutil_escape_html($document->getDocumentTitle()),
- 'Type' => phutil_escape_html($document->getDocumentType()),
- );
- $rows = array();
- foreach ($props as $name => $value) {
- $rows[] = array($name, $value);
- }
- $table = new AphrontTableView($rows);
- $table->setColumnClasses(
- array(
- 'header',
- '',
- ));
- $panel->appendChild($table);
- $panels[] = $panel;
-
-
- $panel = new AphrontPanelView();
- $panel->setHeader('Document Fields');
-
- $fields = $document->getFieldData();
- $rows = array();
- foreach ($fields as $field) {
- list($name, $corpus, $aux_phid) = $field;
- $rows[] = array(
- phutil_escape_html($name),
- phutil_escape_html(nonempty($aux_phid, null)),
- str_replace("\n", '
', phutil_escape_html($corpus)),
- );
- }
-
- $table = new AphrontTableView($rows);
- $table->setHeaders(
- array(
- 'Field',
- 'Aux PHID',
- 'Corpus',
- ));
- $table->setColumnClasses(
- array(
- '',
- '',
- 'wide',
- ));
- $panel->appendChild($table);
- $panels[] = $panel;
-
-
- $panel = new AphrontPanelView();
- $panel->setHeader('Document Relationships');
-
- $relationships = $document->getRelationshipData();
-
- $phids = ipull($relationships, 1);
- $handles = $this->loadViewerHandles($phids);
-
- $rows = array();
- foreach ($relationships as $relationship) {
- list($type, $phid, $rtype, $time) = $relationship;
- $rows[] = array(
- phutil_escape_html($type),
- phutil_escape_html($phid),
- phutil_escape_html($rtype),
- $handles[$phid]->renderLink(),
- );
- }
-
- $table = new AphrontTableView($rows);
- $table->setHeaders(
- array(
- 'Relationship',
- 'Related PHID',
- 'Related Type',
- 'Related Handle',
- ));
- $table->setColumnClasses(
- array(
- '',
- '',
- '',
- 'wide',
- ));
- $panel->appendChild($table);
- $panels[] = $panel;
-
-
- return $this->buildStandardPageResponse(
- $panels,
- array(
- 'title' => 'Raw Index',
- ));
- }
-
-}
diff --git a/src/applications/search/engine/PhabricatorSearchEngineElastic.php b/src/applications/search/engine/PhabricatorSearchEngineElastic.php
index ae3ae91515..aa5273312d 100644
--- a/src/applications/search/engine/PhabricatorSearchEngineElastic.php
+++ b/src/applications/search/engine/PhabricatorSearchEngineElastic.php
@@ -118,6 +118,7 @@ final class PhabricatorSearchEngineElastic extends PhabricatorSearchEngine {
'author' => PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,
'open' => PhabricatorSearchRelationship::RELATIONSHIP_OPEN,
'owner' => PhabricatorSearchRelationship::RELATIONSHIP_OWNER,
+ 'subscribers' => PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER,
'project' => PhabricatorSearchRelationship::RELATIONSHIP_PROJECT,
'repository' => PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY,
);
diff --git a/src/applications/search/engine/PhabricatorSearchEngineMySQL.php b/src/applications/search/engine/PhabricatorSearchEngineMySQL.php
index 28e90ab1d9..cdc95be54e 100644
--- a/src/applications/search/engine/PhabricatorSearchEngineMySQL.php
+++ b/src/applications/search/engine/PhabricatorSearchEngineMySQL.php
@@ -224,6 +224,12 @@ final class PhabricatorSearchEngineMySQL extends PhabricatorSearchEngine {
'owner',
PhabricatorSearchRelationship::RELATIONSHIP_OWNER);
+ $join[] = $this->joinRelationship(
+ $conn_r,
+ $query,
+ 'subscribers',
+ PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER);
+
$join[] = $this->joinRelationship(
$conn_r,
$query,
diff --git a/src/applications/search/view/PhabricatorSearchResultView.php b/src/applications/search/view/PhabricatorSearchResultView.php
index c553e41cee..555f602d40 100644
--- a/src/applications/search/view/PhabricatorSearchResultView.php
+++ b/src/applications/search/view/PhabricatorSearchResultView.php
@@ -26,6 +26,9 @@ final class PhabricatorSearchResultView extends AphrontView {
public function render() {
$handle = $this->handle;
+ if (!$handle->isComplete()) {
+ return;
+ }
$type_name = nonempty($handle->getTypeName(), 'Document');
@@ -66,19 +69,10 @@ final class PhabricatorSearchResultView extends AphrontView {
break;
}
- $index_link = phutil_render_tag(
- 'a',
- array(
- 'href' => '/search/index/'.$handle->getPHID().'/',
- 'style' => 'float: right',
- ),
- 'Examine Index');
-
return
'