15 files changed +80
-115
lines changed Original file line number Diff line number Diff line change 3242
3242
'PhabricatorTransactions' => 'applications/transactions/constants/PhabricatorTransactions.php',
3243
3243
'PhabricatorTransactionsApplication' => 'applications/transactions/application/PhabricatorTransactionsApplication.php',
3244
3244
'PhabricatorTransactionsDestructionEngineExtension' => 'applications/transactions/engineextension/PhabricatorTransactionsDestructionEngineExtension.php',
3245
+ 'PhabricatorTransactionsFulltextEngineExtension' => 'applications/transactions/engineextension/PhabricatorTransactionsFulltextEngineExtension.php',
3245
3246
'PhabricatorTransformedFile' => 'applications/files/storage/PhabricatorTransformedFile.php',
3246
3247
'PhabricatorTranslationsConfigOptions' => 'applications/config/option/PhabricatorTranslationsConfigOptions.php',
3247
3248
'PhabricatorTriggerAction' => 'infrastructure/daemon/workers/action/PhabricatorTriggerAction.php',
7614
7615
'PhabricatorTransactions' => 'Phobject',
7615
7616
'PhabricatorTransactionsApplication' => 'PhabricatorApplication',
7616
7617
'PhabricatorTransactionsDestructionEngineExtension' => 'PhabricatorDestructionEngineExtension',
7618
+ 'PhabricatorTransactionsFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
7617
7619
'PhabricatorTransformedFile' => 'PhabricatorFileDAO',
7618
7620
'PhabricatorTranslationsConfigOptions' => 'PhabricatorApplicationConfigOptions',
7619
7621
'PhabricatorTriggerAction' => 'Phobject',
Original file line number Diff line number Diff line change @@ -41,11 +41,6 @@ protected function buildAbstractDocumentByPHID($phid) {
41
41
PhabricatorCalendarEventPHIDType::TYPECONST ,
42
42
time ());
43
43
44
- $ this ->indexTransactions (
45
- $ doc ,
46
- new PhabricatorCalendarEventTransactionQuery (),
47
- array ($ phid ));
48
-
49
44
return $ doc ;
50
45
}
51
46
Original file line number Diff line number Diff line change @@ -43,11 +43,6 @@ protected function buildAbstractDocumentByPHID($phid) {
43
43
DifferentialRevisionPHIDType::TYPECONST ,
44
44
time ());
45
45
46
- $ this ->indexTransactions (
47
- $ doc ,
48
- new DifferentialTransactionQuery (),
49
- array ($ rev ->getPHID ()));
50
-
51
46
// If a revision needs review, the owners are the reviewers. Otherwise, the
52
47
// owner is the author (e.g., accepted, rejected, closed).
53
48
if ($ rev ->getStatus () == ArcanistDifferentialRevisionStatus::NEEDS_REVIEW ) {
Original file line number Diff line number Diff line change @@ -24,11 +24,6 @@ protected function buildAbstractDocumentByPHID($phid) {
24
24
PhabricatorRepositoryRepositoryPHIDType::TYPECONST ,
25
25
$ book ->getDateCreated ());
26
26
27
- $ this ->indexTransactions (
28
- $ doc ,
29
- new DivinerLiveBookTransactionQuery (),
30
- array ($ phid ));
31
-
32
27
return $ doc ;
33
28
}
34
29
Original file line number Diff line number Diff line change @@ -51,11 +51,6 @@ protected function buildAbstractDocumentByPHID($phid) {
51
51
FundInitiativePHIDType::TYPECONST ,
52
52
time ());
53
53
54
- $ this ->indexTransactions (
55
- $ doc ,
56
- new FundInitiativeTransactionQuery (),
57
- array ($ initiative ->getPHID ()));
58
-
59
54
return $ doc ;
60
55
}
61
56
}
Original file line number Diff line number Diff line change @@ -34,11 +34,6 @@ protected function buildAbstractDocumentByPHID($phid) {
34
34
ManiphestTaskPHIDType::TYPECONST ,
35
35
time ());
36
36
37
- $ this ->indexTransactions (
38
- $ doc ,
39
- new ManiphestTransactionQuery (),
40
- array ($ phid ));
41
-
42
37
$ owner = $ task ->getOwnerPHID ();
43
38
if ($ owner ) {
44
39
$ doc ->addRelationship (
Original file line number Diff line number Diff line change @@ -28,11 +28,6 @@ protected function buildAbstractDocumentByPHID($phid) {
28
28
PassphraseCredentialPHIDType::TYPECONST ,
29
29
time ());
30
30
31
- $ this ->indexTransactions (
32
- $ doc ,
33
- new PassphraseCredentialTransactionQuery (),
34
- array ($ phid ));
35
-
36
31
return $ doc ;
37
32
}
38
33
Original file line number Diff line number Diff line change @@ -24,11 +24,6 @@ protected function buildAbstractDocumentByPHID($phid) {
24
24
PhabricatorPeopleUserPHIDType::TYPECONST ,
25
25
$ mock ->getDateCreated ());
26
26
27
- $ this ->indexTransactions (
28
- $ doc ,
29
- new PholioTransactionQuery (),
30
- array ($ phid ));
31
-
32
27
return $ doc ;
33
28
}
34
29
Original file line number Diff line number Diff line change @@ -37,15 +37,6 @@ protected function buildAbstractDocumentByPHID($phid) {
37
37
}
38
38
}
39
39
40
- $ this ->indexTransactions (
41
- $ doc ,
42
- new PonderQuestionTransactionQuery (),
43
- array ($ phid ));
44
- $ this ->indexTransactions (
45
- $ doc ,
46
- new PonderAnswerTransactionQuery (),
47
- mpull ($ answers , 'getPHID ' ));
48
-
49
40
return $ doc ;
50
41
}
51
42
}
Original file line number Diff line number Diff line change @@ -53,11 +53,6 @@ protected function buildAbstractDocumentByPHID($phid) {
53
53
PhabricatorRepositoryRepositoryPHIDType::TYPECONST ,
54
54
$ date_created );
55
55
56
- $ this ->indexTransactions (
57
- $ doc ,
58
- new PhabricatorAuditTransactionQuery (),
59
- array ($ commit ->getPHID ()));
60
-
61
56
return $ doc ;
62
57
}
63
58
}
Original file line number Diff line number Diff line change @@ -75,26 +75,4 @@ protected function newDocument($phid) {
75
75
->setDocumentType (phid_get_type ($ phid ));
76
76
}
77
77
78
- protected function indexTransactions (
79
- PhabricatorSearchAbstractDocument $ doc ,
80
- PhabricatorApplicationTransactionQuery $ query ,
81
- array $ phids ) {
82
-
83
- $ xactions = id (clone $ query )
84
- ->setViewer ($ this ->getViewer ())
85
- ->withObjectPHIDs ($ phids )
86
- ->execute ();
87
-
88
- foreach ($ xactions as $ xaction ) {
89
- if (!$ xaction ->hasComment ()) {
90
- continue ;
91
- }
92
-
93
- $ comment = $ xaction ->getComment ();
94
- $ doc ->addField (
95
- PhabricatorSearchDocumentFieldType::FIELD_COMMENT ,
96
- $ comment ->getContent ());
97
- }
98
- }
99
-
100
78
}
Original file line number Diff line number Diff line change @@ -17,30 +17,17 @@ public function handleRequest(AphrontRequest $request) {
17
17
if (!$ object ) {
18
18
return new Aphront404Response ();
19
19
}
20
+
20
21
if (!$ object instanceof PhabricatorApplicationTransactionInterface) {
21
22
return new Aphront404Response ();
22
23
}
23
24
24
- $ template = $ object ->getApplicationTransactionTemplate ();
25
- $ queries = id (new PhutilClassMapQuery ())
26
- ->setAncestorClass ('PhabricatorApplicationTransactionQuery ' )
27
- ->execute ();
28
-
29
- $ object_query = null ;
30
- foreach ($ queries as $ query ) {
31
- if ($ query ->getTemplateApplicationTransaction () == $ template ) {
32
- $ object_query = $ query ;
33
- break ;
34
- }
35
- }
36
-
37
- if (!$ object_query ) {
25
+ $ query = PhabricatorApplicationTransactionQuery::newQueryForObject ($ object );
26
+ if (!$ query ) {
38
27
return new Aphront404Response ();
39
28
}
40
29
41
- $ timeline = $ this ->buildTransactionTimeline (
42
- $ object ,
43
- $ query );
30
+ $ timeline = $ this ->buildTransactionTimeline ($ object , $ query );
44
31
45
32
$ phui_timeline = $ timeline ->buildPHUITimelineView ($ with_hiding = false );
46
33
$ phui_timeline ->setShouldAddSpacers (false );
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ final class PhabricatorTransactionsFulltextEngineExtension
4
+ extends PhabricatorFulltextEngineExtension {
5
+
6
+ const EXTENSIONKEY = 'transactions ' ;
7
+
8
+ public function getExtensionName () {
9
+ return pht ('Comments ' );
10
+ }
11
+
12
+ public function shouldIndexFulltextObject ($ object ) {
13
+ return ($ object instanceof PhabricatorApplicationTransactionInterface);
14
+ }
15
+
16
+ public function indexFulltextObject (
17
+ $ object ,
18
+ PhabricatorSearchAbstractDocument $ document ) {
19
+
20
+ $ query = PhabricatorApplicationTransactionQuery::newQueryForObject ($ object );
21
+ if (!$ query ) {
22
+ return ;
23
+ }
24
+
25
+ $ xactions = $ query
26
+ ->setViewer ($ this ->getViewer ())
27
+ ->withObjectPHIDs (array ($ object ->getPHID ()))
28
+ ->needComments (true )
29
+ ->execute ();
30
+
31
+ foreach ($ xactions as $ xaction ) {
32
+ if (!$ xaction ->hasComment ()) {
33
+ continue ;
34
+ }
35
+
36
+ $ comment = $ xaction ->getComment ();
37
+
38
+ $ document ->addField (
39
+ PhabricatorSearchDocumentFieldType::FIELD_COMMENT ,
40
+ $ comment ->getContent ());
41
+ }
42
+ }
43
+
44
+ }
Original file line number Diff line number Diff line change @@ -11,6 +11,27 @@ abstract class PhabricatorApplicationTransactionQuery
11
11
private $ needComments = true ;
12
12
private $ needHandles = true ;
13
13
14
+ final public static function newQueryForObject (
15
+ PhabricatorApplicationTransactionInterface $ object ) {
16
+
17
+ $ xaction = $ object ->getApplicationTransactionTemplate ();
18
+ $ target_class = get_class ($ xaction );
19
+
20
+ $ queries = id (new PhutilClassMapQuery ())
21
+ ->setAncestorClass (__CLASS__ )
22
+ ->execute ();
23
+ foreach ($ queries as $ query ) {
24
+ $ query_xaction = $ query ->getTemplateApplicationTransaction ();
25
+ $ query_class = get_class ($ query_xaction );
26
+
27
+ if ($ query_class === $ target_class ) {
28
+ return id (clone $ query );
29
+ }
30
+ }
31
+
32
+ return null ;
33
+ }
34
+
14
35
abstract public function getTemplateApplicationTransaction ();
15
36
16
37
protected function buildMoreWhereClauses (AphrontDatabaseConnection $ conn_r ) {
Original file line number Diff line number Diff line change @@ -92,8 +92,15 @@ private function loadTransactions(
92
92
93
93
$ viewer = PhabricatorUser::getOmnipotentUser ();
94
94
95
- $ type = phid_get_subtype (head ($ xaction_phids ));
96
- $ xactions = $ this ->buildTransactionQuery ($ type )
95
+ $ query = PhabricatorApplicationTransactionQuery::newQueryForObject ($ object );
96
+ if (!$ query ) {
97
+ throw new PhabricatorWorkerPermanentFailureException (
98
+ pht (
99
+ 'Unable to load query for transaction object "%s"! ' ,
100
+ $ object ->getPHID ()));
101
+ }
102
+
103
+ $ xactions = $ query
97
104
->setViewer ($ viewer )
98
105
->withPHIDs ($ xaction_phids )
99
106
->needComments (true )
@@ -111,29 +118,4 @@ private function loadTransactions(
111
118
return array_select_keys ($ xactions , $ xaction_phids );
112
119
}
113
120
114
-
115
- /**
116
- * Build a new transaction query of the appropriate class so we can load
117
- * the transactions.
118
- */
119
- private function buildTransactionQuery ($ type ) {
120
- $ queries = id (new PhutilClassMapQuery ())
121
- ->setAncestorClass ('PhabricatorApplicationTransactionQuery ' )
122
- ->execute ();
123
-
124
- foreach ($ queries as $ query ) {
125
- $ query_type = $ query
126
- ->getTemplateApplicationTransaction ()
127
- ->getApplicationTransactionType ();
128
- if ($ query_type == $ type ) {
129
- return $ query ;
130
- }
131
- }
132
-
133
- throw new PhabricatorWorkerPermanentFailureException (
134
- pht (
135
- 'Unable to load query for transaction type "%s"! ' ,
136
- $ type ));
137
- }
138
-
139
121
}
0 commit comments