@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.

Remove TYPE_SEARCH_DIDUPDATEINDEX event

Summary:
Ref T9979. This event had one weird callsite and no known third-party callers. It can be done more cleanly as an extension, now.

This index is used to allow us to "Group By: Project" in Maniphest without joining into the Projects database.

Test Plan:
- Ran a query with "Group By: Project" in Maniphest.
- Renamed project "Apples" to "Zebras".
- Reloaded page.
- UI properly moved "Zebras" tasks to the bottom of the list.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T9979

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

+27 -82
+2 -2
src/__phutil_library_map__.php
··· 1294 1294 'ManiphestHovercardEventListener' => 'applications/maniphest/event/ManiphestHovercardEventListener.php', 1295 1295 'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php', 1296 1296 'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php', 1297 - 'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php', 1298 1297 'ManiphestPriorityConfigOptionType' => 'applications/maniphest/config/ManiphestPriorityConfigOptionType.php', 1299 1298 'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php', 1299 + 'ManiphestProjectNameFulltextEngineExtension' => 'applications/maniphest/engineextension/ManiphestProjectNameFulltextEngineExtension.php', 1300 1300 'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php', 1301 1301 'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php', 1302 1302 'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php', ··· 5338 5338 'ManiphestHovercardEventListener' => 'PhabricatorEventListener', 5339 5339 'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod', 5340 5340 'ManiphestNameIndex' => 'ManiphestDAO', 5341 - 'ManiphestNameIndexEventListener' => 'PhabricatorEventListener', 5342 5341 'ManiphestPriorityConfigOptionType' => 'PhabricatorConfigJSONOptionType', 5343 5342 'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand', 5343 + 'ManiphestProjectNameFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension', 5344 5344 'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod', 5345 5345 'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod', 5346 5346 'ManiphestRemarkupRule' => 'PhabricatorObjectRemarkupRule',
-1
src/applications/maniphest/application/PhabricatorManiphestApplication.php
··· 38 38 39 39 public function getEventListeners() { 40 40 return array( 41 - new ManiphestNameIndexEventListener(), 42 41 new ManiphestHovercardEventListener(), 43 42 ); 44 43 }
+25
src/applications/maniphest/engineextension/ManiphestProjectNameFulltextEngineExtension.php
··· 1 + <?php 2 + 3 + final class ManiphestProjectNameFulltextEngineExtension 4 + extends PhabricatorFulltextEngineExtension { 5 + 6 + const EXTENSIONKEY = 'maniphest.project.name'; 7 + 8 + public function getExtensionName() { 9 + return pht('Maniphest Project Name Cache'); 10 + } 11 + 12 + public function shouldIndexFulltextObject($object) { 13 + return ($object instanceof PhabricatorProject); 14 + } 15 + 16 + public function indexFulltextObject( 17 + $object, 18 + PhabricatorSearchAbstractDocument $document) { 19 + 20 + ManiphestNameIndex::updateIndex( 21 + $object->getPHID(), 22 + $object->getName()); 23 + } 24 + 25 + }
-25
src/applications/maniphest/event/ManiphestNameIndexEventListener.php
··· 1 - <?php 2 - 3 - final class ManiphestNameIndexEventListener extends PhabricatorEventListener { 4 - 5 - public function register() { 6 - $this->listen(PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX); 7 - } 8 - 9 - public function handleEvent(PhutilEvent $event) { 10 - $phid = $event->getValue('phid'); 11 - $type = phid_get_type($phid); 12 - 13 - // For now, we only index projects. 14 - if ($type != PhabricatorProjectProjectPHIDType::TYPECONST) { 15 - return; 16 - } 17 - 18 - $document = $event->getValue('document'); 19 - 20 - ManiphestNameIndex::updateIndex( 21 - $phid, 22 - $document->getDocumentTitle()); 23 - } 24 - 25 - }
-17
src/applications/search/index/PhabricatorSearchDocumentIndexer.php
··· 66 66 $engine = PhabricatorSearchEngine::loadEngine(); 67 67 $engine->reindexAbstractDocument($document); 68 68 69 - $this->dispatchDidUpdateIndexEvent($phid, $document); 70 - 71 69 return $this; 72 70 } 73 71 ··· 97 95 PhabricatorSearchDocumentFieldType::FIELD_COMMENT, 98 96 $comment->getContent()); 99 97 } 100 - } 101 - 102 - private function dispatchDidUpdateIndexEvent( 103 - $phid, 104 - PhabricatorSearchAbstractDocument $document) { 105 - 106 - $event = new PhabricatorEvent( 107 - PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX, 108 - array( 109 - 'phid' => $phid, 110 - 'object' => $this->loadDocumentByPHID($phid), 111 - 'document' => $document, 112 - )); 113 - $event->setUser($this->getViewer()); 114 - PhutilEventEngine::dispatchEvent($event); 115 98 } 116 99 117 100 }
-35
src/docs/user/userguide/events.diviner
··· 188 188 189 189 Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query. 190 190 191 - == Search: Did Update Index == 192 - 193 - The constant for this event is 194 - `PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX`. 195 - 196 - This event is dispatched from the Search application's indexing engine, after 197 - it indexes a document. It allows you to publish search-like indexes into other 198 - systems. 199 - 200 - Note that this event happens after the update is fully complete: you can not 201 - prevent or modify the update. Further, the event may fire significantly later 202 - in real time than the update, as indexing may occur in the background. You 203 - should use other events if you need guarantees about when the event executes. 204 - 205 - Finally, this event may fire more than once for a single update. For example, 206 - if the search indexes are rebuilt, this event will fire on objects which have 207 - not actually changed. 208 - 209 - So, good use cases for event listeners are: 210 - 211 - - Updating secondary search indexes. 212 - 213 - Bad use cases are: 214 - 215 - - Editing the object or document. 216 - - Anything with side effects, like sending email. 217 - 218 - Data available on this event: 219 - 220 - - `phid` The PHID of the updated object. 221 - - `object` The object which was updated (like a @{class:ManiphesTask}). 222 - - `document` The @{class:PhabricatorSearchAbstractDocument} which was indexed. 223 - This contains an abstract representation of the object, and may be useful 224 - in populating secondary indexes because it provides a uniform API. 225 - 226 191 == Test: Did Run Test == 227 192 228 193 The constant for this event is
-2
src/infrastructure/events/constant/PhabricatorEventType.php
··· 27 27 const TYPE_AUTH_WILLLOGINUSER = 'auth.willLoginUser'; 28 28 const TYPE_AUTH_DIDVERIFYEMAIL = 'auth.didVerifyEmail'; 29 29 30 - const TYPE_SEARCH_DIDUPDATEINDEX = 'search.didUpdateIndex'; 31 - 32 30 }