Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15412717
D14837.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
13 KB
Referenced Files
None
Subscribers
None
D14837.diff
View Options
diff --git a/src/__phutil_library_map__.php b/src/__phutil_library_map__.php
--- a/src/__phutil_library_map__.php
+++ b/src/__phutil_library_map__.php
@@ -3242,6 +3242,7 @@
'PhabricatorTransactions' => 'applications/transactions/constants/PhabricatorTransactions.php',
'PhabricatorTransactionsApplication' => 'applications/transactions/application/PhabricatorTransactionsApplication.php',
'PhabricatorTransactionsDestructionEngineExtension' => 'applications/transactions/engineextension/PhabricatorTransactionsDestructionEngineExtension.php',
+ 'PhabricatorTransactionsFulltextEngineExtension' => 'applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php',
'PhabricatorTransformedFile' => 'applications/files/storage/PhabricatorTransformedFile.php',
'PhabricatorTranslationsConfigOptions' => 'applications/config/option/PhabricatorTranslationsConfigOptions.php',
'PhabricatorTriggerAction' => 'infrastructure/daemon/workers/action/PhabricatorTriggerAction.php',
@@ -7614,6 +7615,7 @@
'PhabricatorTransactions' => 'Phobject',
'PhabricatorTransactionsApplication' => 'PhabricatorApplication',
'PhabricatorTransactionsDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
+ 'PhabricatorTransactionsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
'PhabricatorTransformedFile' => 'PhabricatorFileDAO',
'PhabricatorTranslationsConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorTriggerAction' => 'Phobject',
diff --git a/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php b/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php
--- a/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php
+++ b/src/applications/calendar/search/PhabricatorCalendarEventSearchIndexer.php
@@ -41,11 +41,6 @@
PhabricatorCalendarEventPHIDType::TYPECONST,
time());
- $this->indexTransactions(
- $doc,
- new PhabricatorCalendarEventTransactionQuery(),
- array($phid));
-
return $doc;
}
diff --git a/src/applications/differential/search/DifferentialSearchIndexer.php b/src/applications/differential/search/DifferentialSearchIndexer.php
--- a/src/applications/differential/search/DifferentialSearchIndexer.php
+++ b/src/applications/differential/search/DifferentialSearchIndexer.php
@@ -43,11 +43,6 @@
DifferentialRevisionPHIDType::TYPECONST,
time());
- $this->indexTransactions(
- $doc,
- new DifferentialTransactionQuery(),
- array($rev->getPHID()));
-
// If a revision needs review, the owners are the reviewers. Otherwise, the
// owner is the author (e.g., accepted, rejected, closed).
if ($rev->getStatus() == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW) {
diff --git a/src/applications/diviner/search/DivinerBookSearchIndexer.php b/src/applications/diviner/search/DivinerBookSearchIndexer.php
--- a/src/applications/diviner/search/DivinerBookSearchIndexer.php
+++ b/src/applications/diviner/search/DivinerBookSearchIndexer.php
@@ -24,11 +24,6 @@
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
$book->getDateCreated());
- $this->indexTransactions(
- $doc,
- new DivinerLiveBookTransactionQuery(),
- array($phid));
-
return $doc;
}
diff --git a/src/applications/fund/search/FundInitiativeIndexer.php b/src/applications/fund/search/FundInitiativeIndexer.php
--- a/src/applications/fund/search/FundInitiativeIndexer.php
+++ b/src/applications/fund/search/FundInitiativeIndexer.php
@@ -51,11 +51,6 @@
FundInitiativePHIDType::TYPECONST,
time());
- $this->indexTransactions(
- $doc,
- new FundInitiativeTransactionQuery(),
- array($initiative->getPHID()));
-
return $doc;
}
}
diff --git a/src/applications/maniphest/search/ManiphestSearchIndexer.php b/src/applications/maniphest/search/ManiphestSearchIndexer.php
--- a/src/applications/maniphest/search/ManiphestSearchIndexer.php
+++ b/src/applications/maniphest/search/ManiphestSearchIndexer.php
@@ -34,11 +34,6 @@
ManiphestTaskPHIDType::TYPECONST,
time());
- $this->indexTransactions(
- $doc,
- new ManiphestTransactionQuery(),
- array($phid));
-
$owner = $task->getOwnerPHID();
if ($owner) {
$doc->addRelationship(
diff --git a/src/applications/passphrase/search/PassphraseSearchIndexer.php b/src/applications/passphrase/search/PassphraseSearchIndexer.php
--- a/src/applications/passphrase/search/PassphraseSearchIndexer.php
+++ b/src/applications/passphrase/search/PassphraseSearchIndexer.php
@@ -28,11 +28,6 @@
PassphraseCredentialPHIDType::TYPECONST,
time());
- $this->indexTransactions(
- $doc,
- new PassphraseCredentialTransactionQuery(),
- array($phid));
-
return $doc;
}
diff --git a/src/applications/pholio/search/PholioSearchIndexer.php b/src/applications/pholio/search/PholioSearchIndexer.php
--- a/src/applications/pholio/search/PholioSearchIndexer.php
+++ b/src/applications/pholio/search/PholioSearchIndexer.php
@@ -24,11 +24,6 @@
PhabricatorPeopleUserPHIDType::TYPECONST,
$mock->getDateCreated());
- $this->indexTransactions(
- $doc,
- new PholioTransactionQuery(),
- array($phid));
-
return $doc;
}
diff --git a/src/applications/ponder/search/PonderSearchIndexer.php b/src/applications/ponder/search/PonderSearchIndexer.php
--- a/src/applications/ponder/search/PonderSearchIndexer.php
+++ b/src/applications/ponder/search/PonderSearchIndexer.php
@@ -37,15 +37,6 @@
}
}
- $this->indexTransactions(
- $doc,
- new PonderQuestionTransactionQuery(),
- array($phid));
- $this->indexTransactions(
- $doc,
- new PonderAnswerTransactionQuery(),
- mpull($answers, 'getPHID'));
-
return $doc;
}
}
diff --git a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
--- a/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
+++ b/src/applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php
@@ -53,11 +53,6 @@
PhabricatorRepositoryRepositoryPHIDType::TYPECONST,
$date_created);
- $this->indexTransactions(
- $doc,
- new PhabricatorAuditTransactionQuery(),
- array($commit->getPHID()));
-
return $doc;
}
}
diff --git a/src/applications/search/index/PhabricatorSearchDocumentIndexer.php b/src/applications/search/index/PhabricatorSearchDocumentIndexer.php
--- a/src/applications/search/index/PhabricatorSearchDocumentIndexer.php
+++ b/src/applications/search/index/PhabricatorSearchDocumentIndexer.php
@@ -75,26 +75,4 @@
->setDocumentType(phid_get_type($phid));
}
- protected function indexTransactions(
- PhabricatorSearchAbstractDocument $doc,
- PhabricatorApplicationTransactionQuery $query,
- array $phids) {
-
- $xactions = id(clone $query)
- ->setViewer($this->getViewer())
- ->withObjectPHIDs($phids)
- ->execute();
-
- foreach ($xactions as $xaction) {
- if (!$xaction->hasComment()) {
- continue;
- }
-
- $comment = $xaction->getComment();
- $doc->addField(
- PhabricatorSearchDocumentFieldType::FIELD_COMMENT,
- $comment->getContent());
- }
- }
-
}
diff --git a/src/applications/transactions/controller/PhabricatorApplicationTransactionShowOlderController.php b/src/applications/transactions/controller/PhabricatorApplicationTransactionShowOlderController.php
--- a/src/applications/transactions/controller/PhabricatorApplicationTransactionShowOlderController.php
+++ b/src/applications/transactions/controller/PhabricatorApplicationTransactionShowOlderController.php
@@ -17,30 +17,17 @@
if (!$object) {
return new Aphront404Response();
}
+
if (!$object instanceof PhabricatorApplicationTransactionInterface) {
return new Aphront404Response();
}
- $template = $object->getApplicationTransactionTemplate();
- $queries = id(new PhutilClassMapQuery())
- ->setAncestorClass('PhabricatorApplicationTransactionQuery')
- ->execute();
-
- $object_query = null;
- foreach ($queries as $query) {
- if ($query->getTemplateApplicationTransaction() == $template) {
- $object_query = $query;
- break;
- }
- }
-
- if (!$object_query) {
+ $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object);
+ if (!$query) {
return new Aphront404Response();
}
- $timeline = $this->buildTransactionTimeline(
- $object,
- $query);
+ $timeline = $this->buildTransactionTimeline($object, $query);
$phui_timeline = $timeline->buildPHUITimelineView($with_hiding = false);
$phui_timeline->setShouldAddSpacers(false);
diff --git a/src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php b/src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php
new file mode 100644
--- /dev/null
+++ b/src/applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php
@@ -0,0 +1,44 @@
+<?php
+
+final class PhabricatorTransactionsFulltextEngineExtension
+ extends PhabricatorFulltextEngineExtension {
+
+ const EXTENSIONKEY = 'transactions';
+
+ public function getExtensionName() {
+ return pht('Comments');
+ }
+
+ public function shouldIndexFulltextObject($object) {
+ return ($object instanceof PhabricatorApplicationTransactionInterface);
+ }
+
+ public function indexFulltextObject(
+ $object,
+ PhabricatorSearchAbstractDocument $document) {
+
+ $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object);
+ if (!$query) {
+ return;
+ }
+
+ $xactions = $query
+ ->setViewer($this->getViewer())
+ ->withObjectPHIDs(array($object->getPHID()))
+ ->needComments(true)
+ ->execute();
+
+ foreach ($xactions as $xaction) {
+ if (!$xaction->hasComment()) {
+ continue;
+ }
+
+ $comment = $xaction->getComment();
+
+ $document->addField(
+ PhabricatorSearchDocumentFieldType::FIELD_COMMENT,
+ $comment->getContent());
+ }
+ }
+
+}
diff --git a/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php b/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php
--- a/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php
+++ b/src/applications/transactions/query/PhabricatorApplicationTransactionQuery.php
@@ -11,6 +11,27 @@
private $needComments = true;
private $needHandles = true;
+ final public static function newQueryForObject(
+ PhabricatorApplicationTransactionInterface $object) {
+
+ $xaction = $object->getApplicationTransactionTemplate();
+ $target_class = get_class($xaction);
+
+ $queries = id(new PhutilClassMapQuery())
+ ->setAncestorClass(__CLASS__)
+ ->execute();
+ foreach ($queries as $query) {
+ $query_xaction = $query->getTemplateApplicationTransaction();
+ $query_class = get_class($query_xaction);
+
+ if ($query_class === $target_class) {
+ return id(clone $query);
+ }
+ }
+
+ return null;
+ }
+
abstract public function getTemplateApplicationTransaction();
protected function buildMoreWhereClauses(AphrontDatabaseConnection $conn_r) {
diff --git a/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php b/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
--- a/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
+++ b/src/applications/transactions/worker/PhabricatorApplicationTransactionPublishWorker.php
@@ -92,8 +92,15 @@
$viewer = PhabricatorUser::getOmnipotentUser();
- $type = phid_get_subtype(head($xaction_phids));
- $xactions = $this->buildTransactionQuery($type)
+ $query = PhabricatorApplicationTransactionQuery::newQueryForObject($object);
+ if (!$query) {
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht(
+ 'Unable to load query for transaction object "%s"!',
+ $object->getPHID()));
+ }
+
+ $xactions = $query
->setViewer($viewer)
->withPHIDs($xaction_phids)
->needComments(true)
@@ -111,29 +118,4 @@
return array_select_keys($xactions, $xaction_phids);
}
-
- /**
- * Build a new transaction query of the appropriate class so we can load
- * the transactions.
- */
- private function buildTransactionQuery($type) {
- $queries = id(new PhutilClassMapQuery())
- ->setAncestorClass('PhabricatorApplicationTransactionQuery')
- ->execute();
-
- foreach ($queries as $query) {
- $query_type = $query
- ->getTemplateApplicationTransaction()
- ->getApplicationTransactionType();
- if ($query_type == $type) {
- return $query;
- }
- }
-
- throw new PhabricatorWorkerPermanentFailureException(
- pht(
- 'Unable to load query for transaction type "%s"!',
- $type));
- }
-
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Thu, Mar 20, 2:34 PM (2 d, 1 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7624335
Default Alt Text
D14837.diff (13 KB)
Attached To
Mode
D14837: Modularize transaction/comment indexing in the FulltextEngine
Attached
Detach File
Event Timeline
Log In to Comment