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

Separate fulltext engine extensions into "enrich" and "index" phases

Summary:
Ref T12819. Some of the extensions "enrich" the document (adding more fields or relationships), while others "index" it (insert it into some kind of index for later searching).

Currently, these are all muddled under a single "index" phase. However, the Ferret extension cares about fields and relationships which other extensions may add.

Split this into two phases: "enrich" adds fields and relationships so other extensions can read them later if they want. "Index" happens after the document is built and has all the fields and relationships.

The specific problem this solves is that comments may not have been added to the document when the Ferret extension runs. By moving them to the "enrich" phase, the Ferret engine will be able to see and index comments.

Test Plan: Ran `bin/search index ...`, grepped for `indexFulltextDocument`.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T12819

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

+41 -16
+2 -2
src/applications/project/engineextension/PhabricatorProjectsFulltextEngineExtension.php
··· 9 9 return pht('Projects'); 10 10 } 11 11 12 - public function shouldIndexFulltextObject($object) { 12 + public function shouldEnrichFulltextObject($object) { 13 13 return ($object instanceof PhabricatorProjectInterface); 14 14 } 15 15 16 - public function indexFulltextObject( 16 + public function enrichFulltextObject( 17 17 $object, 18 18 PhabricatorSearchAbstractDocument $document) { 19 19
+2 -2
src/applications/search/engineextension/PhabricatorLiskFulltextEngineExtension.php
··· 9 9 return pht('Lisk Builtin Properties'); 10 10 } 11 11 12 - public function shouldIndexFulltextObject($object) { 12 + public function shouldEnrichFulltextObject($object) { 13 13 if (!($object instanceof PhabricatorLiskDAO)) { 14 14 return false; 15 15 } ··· 21 21 return true; 22 22 } 23 23 24 - public function indexFulltextObject( 24 + public function enrichFulltextObject( 25 25 $object, 26 26 PhabricatorSearchAbstractDocument $document) { 27 27
+14 -3
src/applications/search/index/PhabricatorFulltextEngine.php
··· 26 26 $object = $this->getObject(); 27 27 28 28 $extensions = PhabricatorFulltextEngineExtension::getAllExtensions(); 29 + 30 + $enrich_extensions = array(); 31 + $index_extensions = array(); 29 32 foreach ($extensions as $key => $extension) { 30 - if (!$extension->shouldIndexFulltextObject($object)) { 31 - unset($extensions[$key]); 33 + if ($extension->shouldEnrichFulltextObject($object)) { 34 + $enrich_extensions[] = $extension; 35 + } 36 + 37 + if ($extension->shouldIndexFulltextObject($object)) { 38 + $index_extensions[] = $extension; 32 39 } 33 40 } 34 41 ··· 36 43 37 44 $this->buildAbstractDocument($document, $object); 38 45 39 - foreach ($extensions as $extension) { 46 + foreach ($enrich_extensions as $extension) { 47 + $extension->enrichFulltextObject($object, $document); 48 + } 49 + 50 + foreach ($index_extensions as $extension) { 40 51 $extension->indexFulltextObject($object, $document); 41 52 } 42 53
+17 -3
src/applications/search/index/PhabricatorFulltextEngineExtension.php
··· 12 12 13 13 abstract public function getExtensionName(); 14 14 15 - abstract public function shouldIndexFulltextObject($object); 15 + public function shouldEnrichFulltextObject($object) { 16 + return false; 17 + } 16 18 17 - abstract public function indexFulltextObject( 19 + public function enrichFulltextObject( 18 20 $object, 19 - PhabricatorSearchAbstractDocument $document); 21 + PhabricatorSearchAbstractDocument $document) { 22 + return; 23 + } 24 + 25 + public function shouldIndexFulltextObject($object) { 26 + return false; 27 + } 28 + 29 + public function indexFulltextObject( 30 + $object, 31 + PhabricatorSearchAbstractDocument $document) { 32 + return; 33 + } 20 34 21 35 final public static function getAllExtensions() { 22 36 return id(new PhutilClassMapQuery())
+2 -2
src/applications/subscriptions/engineextension/PhabricatorSubscriptionsFulltextEngineExtension.php
··· 9 9 return pht('Subscribers'); 10 10 } 11 11 12 - public function shouldIndexFulltextObject($object) { 12 + public function shouldEnrichFulltextObject($object) { 13 13 return ($object instanceof PhabricatorSubscribableInterface); 14 14 } 15 15 16 - public function indexFulltextObject( 16 + public function enrichFulltextObject( 17 17 $object, 18 18 PhabricatorSearchAbstractDocument $document) { 19 19
+2 -2
src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php
··· 9 9 return pht('Comments'); 10 10 } 11 11 12 - public function shouldIndexFulltextObject($object) { 12 + public function shouldEnrichFulltextObject($object) { 13 13 return ($object instanceof PhabricatorApplicationTransactionInterface); 14 14 } 15 15 16 - public function indexFulltextObject( 16 + public function enrichFulltextObject( 17 17 $object, 18 18 PhabricatorSearchAbstractDocument $document) { 19 19
+2 -2
src/infrastructure/customfield/engineextension/PhabricatorCustomFieldFulltextEngineExtension.php
··· 9 9 return pht('Custom Fields'); 10 10 } 11 11 12 - public function shouldIndexFulltextObject($object) { 12 + public function shouldEnrichFulltextObject($object) { 13 13 return ($object instanceof PhabricatorCustomFieldInterface); 14 14 } 15 15 16 - public function indexFulltextObject( 16 + public function enrichFulltextObject( 17 17 $object, 18 18 PhabricatorSearchAbstractDocument $document) { 19 19