@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Expose subscribers in search and some polish

Summary: was poking at T654 and noticed subscribers weren't exposed in search UI so I did so. Also make ponder a little less silly on the double handles load. Finally, stopped showing the "Examine Index" link to non admins since they can't click it. Note this introduces a UI oddity in that you Users and Phriction Documents don't currently have the subscribe functionality.

Test Plan: searched for subscribers in all applications - it worked!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3907

+51 -144
+4
src/applications/base/controller/PhabricatorController.php
··· 225 225 return $this; 226 226 } 227 227 228 + protected function getLoadedHandles() { 229 + return $this->handles; 230 + } 231 + 228 232 protected function loadViewerHandles(array $phids) { 229 233 return id(new PhabricatorObjectHandleData($phids)) 230 234 ->setViewer($this->getRequest()->getUser())
+1 -1
src/applications/ponder/controller/PonderQuestionViewController.php
··· 41 41 42 42 $object_phids = array_merge($object_phids, $subscribers); 43 43 44 - $handles = $this->loadViewerHandles($object_phids); 45 44 $this->loadHandles($object_phids); 45 + $handles = $this->getLoadedHandles(); 46 46 47 47 $detail_panel = new PonderQuestionDetailView(); 48 48 $detail_panel
+13
src/applications/ponder/search/PhabricatorSearchPonderIndexer.php
··· 48 48 } 49 49 } 50 50 51 + $subscribers = PhabricatorSubscribersQuery::loadSubscribersForPHID( 52 + $question->getPHID()); 53 + $handles = id(new PhabricatorObjectHandleData($subscribers)) 54 + ->loadHandles(); 55 + 56 + foreach ($handles as $phid => $handle) { 57 + $doc->addRelationship( 58 + PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, 59 + $phid, 60 + $handle->getType(), 61 + $question->getDateModified()); // Bogus timestamp. 62 + } 63 + 51 64 self::reindexAbstractDocument($doc); 52 65 } 53 66 }
+23 -5
src/applications/search/controller/PhabricatorSearchController.php
··· 81 81 $query->setParameter('owner', $request->getArr('owner')); 82 82 } 83 83 84 + if ($request->getArr('subscribers')) { 85 + $query->setParameter('subscribers', 86 + $request->getArr('subscribers')); 87 + } 88 + 84 89 if ($request->getInt('open')) { 85 90 $query->setParameter('open', $request->getInt('open')); 86 91 } ··· 109 114 $phids = array_merge( 110 115 $query->getParameter('author', array()), 111 116 $query->getParameter('owner', array()), 117 + $query->getParameter('subscribers', array()), 112 118 $query->getParameter('project', array()) 113 119 ); 114 120 ··· 124 130 $query->getParameter('owner', array())); 125 131 $owner_value = mpull($owner_value, 'getFullName', 'getPHID'); 126 132 133 + $subscribers_value = array_select_keys( 134 + $handles, 135 + $query->getParameter('subscribers', array())); 136 + $subscribers_value = mpull($subscribers_value, 'getFullName', 'getPHID'); 137 + 127 138 $project_value = array_select_keys( 128 139 $handles, 129 140 $query->getParameter('project', array())); ··· 174 185 'Tip: search for "Up For Grabs" to find unowned documents.')) 175 186 ->appendChild( 176 187 id(new AphrontFormTokenizerControl()) 188 + ->setName('subscribers') 189 + ->setLabel('Subscribers') 190 + ->setDatasource('/typeahead/common/users/') 191 + ->setValue($subscribers_value)) 192 + ->appendChild( 193 + id(new AphrontFormTokenizerControl()) 177 194 ->setName('project') 178 195 ->setLabel('Project') 179 196 ->setDatasource('/typeahead/common/projects/') ··· 213 230 214 231 if ($results) { 215 232 216 - $loader = new PhabricatorObjectHandleData($results); 233 + $loader = id(new PhabricatorObjectHandleData($results)) 234 + ->setViewer($user); 217 235 $handles = $loader->loadHandles(); 218 236 $objects = $loader->loadObjects(); 219 237 $results = array(); 220 238 foreach ($handles as $phid => $handle) { 221 - $view = new PhabricatorSearchResultView(); 222 - $view->setHandle($handle); 223 - $view->setQuery($query); 224 - $view->setObject(idx($objects, $phid)); 239 + $view = id(new PhabricatorSearchResultView()) 240 + ->setHandle($handle) 241 + ->setQuery($query) 242 + ->setObject(idx($objects, $phid)); 225 243 $results[] = $view->render(); 226 244 } 227 245 $results =
-129
src/applications/search/controller/PhabricatorSearchIndexController.php
··· 1 - <?php 2 - 3 - /** 4 - * @group search 5 - */ 6 - final class PhabricatorSearchIndexController 7 - extends PhabricatorSearchBaseController { 8 - 9 - private $phid; 10 - 11 - public function shouldRequireAdmin() { 12 - // This basically shows you all the text of any object in the system, so 13 - // make it admin-only. 14 - return true; 15 - } 16 - 17 - public function willProcessRequest(array $data) { 18 - $this->phid = $data['phid']; 19 - } 20 - 21 - public function processRequest() { 22 - 23 - $engine = PhabricatorSearchEngineSelector::newSelector()->newEngine(); 24 - $document = $engine->reconstructDocument($this->phid); 25 - if (!$document) { 26 - return new Aphront404Response(); 27 - } 28 - 29 - $panels = array(); 30 - 31 - $panel = new AphrontPanelView(); 32 - $panel->setHeader('Abstract Document Index'); 33 - 34 - $props = array( 35 - 'PHID' => phutil_escape_html($document->getPHID()), 36 - 'Title' => phutil_escape_html($document->getDocumentTitle()), 37 - 'Type' => phutil_escape_html($document->getDocumentType()), 38 - ); 39 - $rows = array(); 40 - foreach ($props as $name => $value) { 41 - $rows[] = array($name, $value); 42 - } 43 - $table = new AphrontTableView($rows); 44 - $table->setColumnClasses( 45 - array( 46 - 'header', 47 - '', 48 - )); 49 - $panel->appendChild($table); 50 - $panels[] = $panel; 51 - 52 - 53 - $panel = new AphrontPanelView(); 54 - $panel->setHeader('Document Fields'); 55 - 56 - $fields = $document->getFieldData(); 57 - $rows = array(); 58 - foreach ($fields as $field) { 59 - list($name, $corpus, $aux_phid) = $field; 60 - $rows[] = array( 61 - phutil_escape_html($name), 62 - phutil_escape_html(nonempty($aux_phid, null)), 63 - str_replace("\n", '<br />', phutil_escape_html($corpus)), 64 - ); 65 - } 66 - 67 - $table = new AphrontTableView($rows); 68 - $table->setHeaders( 69 - array( 70 - 'Field', 71 - 'Aux PHID', 72 - 'Corpus', 73 - )); 74 - $table->setColumnClasses( 75 - array( 76 - '', 77 - '', 78 - 'wide', 79 - )); 80 - $panel->appendChild($table); 81 - $panels[] = $panel; 82 - 83 - 84 - $panel = new AphrontPanelView(); 85 - $panel->setHeader('Document Relationships'); 86 - 87 - $relationships = $document->getRelationshipData(); 88 - 89 - $phids = ipull($relationships, 1); 90 - $handles = $this->loadViewerHandles($phids); 91 - 92 - $rows = array(); 93 - foreach ($relationships as $relationship) { 94 - list($type, $phid, $rtype, $time) = $relationship; 95 - $rows[] = array( 96 - phutil_escape_html($type), 97 - phutil_escape_html($phid), 98 - phutil_escape_html($rtype), 99 - $handles[$phid]->renderLink(), 100 - ); 101 - } 102 - 103 - $table = new AphrontTableView($rows); 104 - $table->setHeaders( 105 - array( 106 - 'Relationship', 107 - 'Related PHID', 108 - 'Related Type', 109 - 'Related Handle', 110 - )); 111 - $table->setColumnClasses( 112 - array( 113 - '', 114 - '', 115 - '', 116 - 'wide', 117 - )); 118 - $panel->appendChild($table); 119 - $panels[] = $panel; 120 - 121 - 122 - return $this->buildStandardPageResponse( 123 - $panels, 124 - array( 125 - 'title' => 'Raw Index', 126 - )); 127 - } 128 - 129 - }
+1
src/applications/search/engine/PhabricatorSearchEngineElastic.php
··· 118 118 'author' => PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR, 119 119 'open' => PhabricatorSearchRelationship::RELATIONSHIP_OPEN, 120 120 'owner' => PhabricatorSearchRelationship::RELATIONSHIP_OWNER, 121 + 'subscribers' => PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER, 121 122 'project' => PhabricatorSearchRelationship::RELATIONSHIP_PROJECT, 122 123 'repository' => PhabricatorSearchRelationship::RELATIONSHIP_REPOSITORY, 123 124 );
+6
src/applications/search/engine/PhabricatorSearchEngineMySQL.php
··· 227 227 $join[] = $this->joinRelationship( 228 228 $conn_r, 229 229 $query, 230 + 'subscribers', 231 + PhabricatorSearchRelationship::RELATIONSHIP_SUBSCRIBER); 232 + 233 + $join[] = $this->joinRelationship( 234 + $conn_r, 235 + $query, 230 236 'project', 231 237 PhabricatorSearchRelationship::RELATIONSHIP_PROJECT); 232 238
+3 -9
src/applications/search/view/PhabricatorSearchResultView.php
··· 26 26 27 27 public function render() { 28 28 $handle = $this->handle; 29 + if (!$handle->isComplete()) { 30 + return; 31 + } 29 32 30 33 $type_name = nonempty($handle->getTypeName(), 'Document'); 31 34 ··· 66 69 break; 67 70 } 68 71 69 - $index_link = phutil_render_tag( 70 - 'a', 71 - array( 72 - 'href' => '/search/index/'.$handle->getPHID().'/', 73 - 'style' => 'float: right', 74 - ), 75 - 'Examine Index'); 76 - 77 72 return 78 73 '<div class="phabricator-search-result">'. 79 74 $img. 80 75 '<div class="result-desc">'. 81 - $index_link. 82 76 phutil_render_tag( 83 77 'a', 84 78 array(