3 final class PhabricatorTransactionsFulltextEngineExtension
4 extends PhabricatorFulltextEngineExtension
{
6 const EXTENSIONKEY
= 'transactions';
8 public function getExtensionName() {
9 return pht('Comments');
12 public function shouldEnrichFulltextObject($object) {
13 return ($object instanceof PhabricatorApplicationTransactionInterface
);
16 public function enrichFulltextObject(
18 PhabricatorSearchAbstractDocument
$document) {
20 $query = PhabricatorApplicationTransactionQuery
::newQueryForObject($object);
26 ->setViewer($this->getViewer())
27 ->withObjectPHIDs(array($object->getPHID()))
31 // See PHI719. Users occasionally create objects with huge numbers of
32 // comments, which can be slow to index. We handle this with reasonable
33 // grace: at time of writing, we can index a task with 100K comments in
34 // about 30 seconds. However, we do need to hold all the comments in
35 // memory in the AbstractDocument, so there's some practical limit to what
36 // we can realistically index.
38 // Since objects with more than 1,000 comments are not likely to be
39 // legitimate objects with actual discussion, index only the first
43 ->setOrderVector(array('-id'))
46 $xactions = $query->execute();
48 foreach ($xactions as $xaction) {
49 if (!$xaction->hasComment()) {
53 $comment = $xaction->getComment();
56 PhabricatorSearchDocumentFieldType
::FIELD_COMMENT
,
57 $comment->getContent());