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

Add support for differential field specifications to be indexed in search

Summary: ...and do so for a few fields -- summary, test plan, and revert plan.

Test Plan: added NATASHA and BULLWINKLE to summary and test plan of existing diff. Diff showed up in search!

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Maniphest Tasks: T654

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

+80 -7
+25
src/applications/differential/field/specification/DifferentialFieldSpecification.php
··· 383 383 return $key; 384 384 } 385 385 386 + /* -( Extending the Search Interface )------------------------------------ */ 387 + 388 + /** 389 + * @task search 390 + */ 391 + public function shouldAddToSearchIndex() { 392 + return false; 393 + } 394 + 395 + /** 396 + * @task search 397 + */ 398 + public function getValueForSearchIndex() { 399 + throw new DifferentialFieldSpecificationIncompleteException($this); 400 + } 401 + 402 + /** 403 + * NOTE: Keys *must be* 4 characters for 404 + * @{class:PhabricatorSearchEngineMySQL}. 405 + * 406 + * @task search 407 + */ 408 + public function getKeyForSearchIndex() { 409 + throw new DifferentialFieldSpecificationIncompleteException($this); 410 + } 386 411 387 412 /* -( Extending Commit Messages )------------------------------------------ */ 388 413
+12
src/applications/differential/field/specification/DifferentialRevertPlanFieldSpecification.php
··· 95 95 return $value; 96 96 } 97 97 98 + public function shouldAddToSearchIndex() { 99 + return true; 100 + } 101 + 102 + public function getValueForSearchIndex() { 103 + return $this->value; 104 + } 105 + 106 + public function getKeyForSearchIndex() { 107 + return 'rpln'; 108 + } 109 + 98 110 }
+12
src/applications/differential/field/specification/DifferentialSummaryFieldSpecification.php
··· 70 70 return $this->summary; 71 71 } 72 72 73 + public function shouldAddToSearchIndex() { 74 + return true; 75 + } 76 + 77 + public function getValueForSearchIndex() { 78 + return $this->summary; 79 + } 80 + 81 + public function getKeyForSearchIndex() { 82 + return PhabricatorSearchField::FIELD_BODY; 83 + } 84 + 73 85 }
+14
src/applications/differential/field/specification/DifferentialTestPlanFieldSpecification.php
··· 103 103 return "TEST PLAN\n".preg_replace('/^/m', ' ', $this->plan); 104 104 } 105 105 106 + public function shouldAddToSearchIndex() { 107 + return true; 108 + } 109 + 110 + public function getValueForSearchIndex() { 111 + return $this->plan; 112 + } 113 + 114 + public function getKeyForSearchIndex() { 115 + return 'tpln'; 116 + } 117 + 106 118 private function isRequired() { 107 119 return PhabricatorEnv::getEnvConfig('differential.require-test-plan-field'); 108 120 } 121 + 122 + 109 123 110 124 }
-1
src/applications/search/constants/PhabricatorSearchField.php
··· 7 7 8 8 const FIELD_TITLE = 'titl'; 9 9 const FIELD_BODY = 'body'; 10 - const FIELD_TEST_PLAN = 'tpln'; 11 10 const FIELD_COMMENT = 'cmnt'; 12 11 13 12 }
+17 -6
src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php
··· 14 14 $doc->setDocumentCreated($rev->getDateCreated()); 15 15 $doc->setDocumentModified($rev->getDateModified()); 16 16 17 - $doc->addField( 18 - PhabricatorSearchField::FIELD_BODY, 19 - $rev->getSummary()); 20 - $doc->addField( 21 - PhabricatorSearchField::FIELD_TEST_PLAN, 22 - $rev->getTestPlan()); 17 + $aux_fields = DifferentialFieldSelector::newSelector() 18 + ->getFieldSpecifications(); 19 + foreach ($aux_fields as $key => $aux_field) { 20 + if (!$aux_field->shouldAddToSearchIndex()) { 21 + unset($aux_fields[$key]); 22 + } 23 + } 24 + 25 + $aux_fields = DifferentialAuxiliaryField::loadFromStorage( 26 + $rev, 27 + $aux_fields); 28 + foreach ($aux_fields as $aux_field) { 29 + $doc->addField( 30 + $aux_field->getKeyForSearchIndex(), 31 + $aux_field->getValueForSearchIndex() 32 + ); 33 + } 23 34 24 35 $doc->addRelationship( 25 36 PhabricatorSearchRelationship::RELATIONSHIP_AUTHOR,