Differential D19503 Diff 46634 src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php
Show All 16 Lines | public function enrichFulltextObject( | ||||
$object, | $object, | ||||
PhabricatorSearchAbstractDocument $document) { | PhabricatorSearchAbstractDocument $document) { | ||||
$query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); | $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object); | ||||
if (!$query) { | if (!$query) { | ||||
return; | return; | ||||
} | } | ||||
$xactions = $query | $query | ||||
->setViewer($this->getViewer()) | ->setViewer($this->getViewer()) | ||||
->withObjectPHIDs(array($object->getPHID())) | ->withObjectPHIDs(array($object->getPHID())) | ||||
->withComments(true) | ->withComments(true) | ||||
->needComments(true) | ->needComments(true); | ||||
->execute(); | |||||
// See PHI719. Users occasionally create objects with huge numbers of | |||||
// comments, which can be slow to index. We handle this with reasonable | |||||
// grace: at time of writing, we can index a task with 100K comments in | |||||
// about 30 seconds. However, we do need to hold all the comments in | |||||
// memory in the AbstractDocument, so there's some practical limit to what | |||||
// we can realistically index. | |||||
// Since objects with more than 1,000 comments are not likely to be | |||||
// legitimate objects with actual discussion, index only the first | |||||
// thousand comments. | |||||
$query | |||||
->setOrderVector(array('-id')) | |||||
->setLimit(1000); | |||||
$xactions = $query->execute(); | |||||
foreach ($xactions as $xaction) { | foreach ($xactions as $xaction) { | ||||
if (!$xaction->hasComment()) { | if (!$xaction->hasComment()) { | ||||
continue; | continue; | ||||
} | } | ||||
$comment = $xaction->getComment(); | $comment = $xaction->getComment(); | ||||
$document->addField( | $document->addField( | ||||
PhabricatorSearchDocumentFieldType::FIELD_COMMENT, | PhabricatorSearchDocumentFieldType::FIELD_COMMENT, | ||||
$comment->getContent()); | $comment->getContent()); | ||||
} | } | ||||
} | } | ||||
} | } |