Skip to content

Commit f6b1964

Browse files
author
epriestley
committed
Improve Search architecture
Summary: The search indexing API has several problems right now: - Always runs in-process. - It would be nice to push this into the task queue for performance. However, the API currently passses an object all the way through (and some indexers depend on preloaded object attributes), so it can't be dumped into the task queue at any stage since we can't serialize it. - Being able to use the task queue will also make rebuilding indexes faster. - Instead, make the API phid-oriented. - No uniform indexing API. - Each "Editor" currently calls SomeCustomIndexer::indexThing(). This won't work with AbstractTransactions. The API is also just weird. - Instead, provide a uniform API. - No uniform CLI. - We have `scripts/search/reindex_everything.php`, but it doesn't actually index everything. Each new document type needs to be separately added to it, leading to stuff like D3839. Third-party applications can't provide indexers. - Instead, let indexers expose documents for indexing. - Not application-oriented. - All the indexers live in search/ right now, which isn't the right organization in an application-orietned view of the world. - Instead, move indexers to applications and load them with SymbolLoader. Test Plan: - `bin/search index` - Indexed one revision, one task. - Indexed `--type TASK`, `--type DREV`, etc., for all types. - Indexed `--all`. - Added the word "saboteur" to a revision, task, wiki page, and question and then searched for it. - Creating users is a pain; searched for a user after indexing. - Creating commits is a pain; searched for a commit after indexing. - Mocks aren't currently loadable in the result view, so their indexing is moot. Reviewers: btrahan, vrana Reviewed By: btrahan CC: 20after4, aran Maniphest Tasks: T1991, T2104 Differential Revision: https://secure.phabricator.com/D4261
1 parent aae5f9e commit f6b1964

30 files changed

+386
-161
lines changed

bin/search

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../scripts/search/manage_search.php

scripts/search/index_one_commit.php

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$root = dirname(dirname(dirname(__FILE__)));
5-
require_once $root.'/scripts/__init_script__.php';
6-
7-
if (empty($argv[1])) {
8-
echo "usage: index_one_commit.php <commit_name>\n";
9-
die(1);
10-
}
11-
12-
$commit = isset($argv[1]) ? $argv[1] : null;
13-
if (!$commit) {
14-
throw new Exception("Provide a commit to index!");
15-
}
16-
$matches = null;
17-
if (!preg_match('/r([A-Z]+)([a-z0-9]+)/', $commit, $matches)) {
18-
throw new Exception("Can't parse commit identifier!");
19-
}
20-
$repo = id(new PhabricatorRepository())->loadOneWhere(
21-
'callsign = %s',
22-
$matches[1]);
23-
if (!$repo) {
24-
throw new Exception("Unknown repository!");
25-
}
26-
27-
$commit = id(new PhabricatorRepositoryCommit())->loadOneWhere(
28-
'repositoryID = %d AND commitIdentifier = %s',
29-
$repo->getID(),
30-
$matches[2]);
31-
if (!$commit) {
32-
throw new Exception('Unknown commit.');
33-
}
34-
35-
PhabricatorSearchCommitIndexer::indexCommit($commit);
36-
echo "Done.\n";
4+
echo "Use 'bin/search index rXnnnnnn' instead of this script.\n";
5+
exit(1);

scripts/search/manage_search.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env php
2+
<?php
3+
4+
$root = dirname(dirname(dirname(__FILE__)));
5+
require_once $root.'/scripts/__init_script__.php';
6+
7+
$args = new PhutilArgumentParser($argv);
8+
$args->setTagline('manage search');
9+
$args->setSynopsis(<<<EOSYNOPSIS
10+
**search** __command__ [__options__]
11+
Manage Phabricator search index.
12+
13+
EOSYNOPSIS
14+
);
15+
$args->parseStandardArguments();
16+
17+
$workflows = array(
18+
new PhabricatorSearchManagementIndexWorkflow(),
19+
new PhutilHelpArgumentWorkflow(),
20+
);
21+
22+
$args->parseWorkflows($workflows);

scripts/search/reindex_all_users.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$root = dirname(dirname(dirname(__FILE__)));
5-
require_once $root.'/scripts/__init_script__.php';
6-
7-
$users = id(new PhabricatorUser())->loadAll();
8-
echo "Indexing ".count($users)." users";
9-
foreach ($users as $user) {
10-
PhabricatorSearchUserIndexer::indexUser($user);
11-
echo '.';
12-
}
13-
echo "\n";
14-
echo "Done.\n";
15-
4+
echo "Use 'bin/search index --type USER' instead of this script.\n";
5+
die(1);

scripts/search/reindex_everything.php

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,5 @@
11
#!/usr/bin/env php
22
<?php
33

4-
$root = dirname(dirname(dirname(__FILE__)));
5-
require_once $root.'/scripts/__init_script__.php';
6-
7-
// TODO: Get rid of this script eventually, once this stuff is better-formalized
8-
// in Timeline consumers.
9-
10-
echo "Reindexing revisions...\n";
11-
$revs = new LiskMigrationIterator(new DifferentialRevision());
12-
foreach ($revs as $rev) {
13-
PhabricatorSearchDifferentialIndexer::indexRevision($rev);
14-
echo '.';
15-
}
16-
echo "\n";
17-
18-
echo "Reindexing commits...\n";
19-
$commits = new LiskMigrationIterator(new PhabricatorRepositoryCommit());
20-
foreach ($commits as $commit) {
21-
PhabricatorSearchCommitIndexer::indexCommit($commit);
22-
echo '.';
23-
}
24-
echo "\n";
25-
26-
echo "Reindexing tasks...\n";
27-
$tasks = new LiskMigrationIterator(new ManiphestTask());
28-
foreach ($tasks as $task) {
29-
PhabricatorSearchManiphestIndexer::indexTask($task);
30-
echo '.';
31-
}
32-
echo "\n";
33-
34-
include dirname(__FILE__).'/reindex_all_users.php';
4+
echo "Use 'bin/search index --all' instead of this script.\n";
5+
die(1);

src/__phutil_library_map__.php

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@
310310
'DifferentialRevisionStatusFieldSpecification' => 'applications/differential/field/specification/DifferentialRevisionStatusFieldSpecification.php',
311311
'DifferentialRevisionUpdateHistoryView' => 'applications/differential/view/DifferentialRevisionUpdateHistoryView.php',
312312
'DifferentialRevisionViewController' => 'applications/differential/controller/DifferentialRevisionViewController.php',
313+
'DifferentialSearchIndexer' => 'applications/differential/search/DifferentialSearchIndexer.php',
313314
'DifferentialSubscribeController' => 'applications/differential/controller/DifferentialSubscribeController.php',
314315
'DifferentialSummaryFieldSpecification' => 'applications/differential/field/specification/DifferentialSummaryFieldSpecification.php',
315316
'DifferentialTasksAttacher' => 'applications/differential/DifferentialTasksAttacher.php',
@@ -533,6 +534,7 @@
533534
'ManiphestSavedQueryDeleteController' => 'applications/maniphest/controller/ManiphestSavedQueryDeleteController.php',
534535
'ManiphestSavedQueryEditController' => 'applications/maniphest/controller/ManiphestSavedQueryEditController.php',
535536
'ManiphestSavedQueryListController' => 'applications/maniphest/controller/ManiphestSavedQueryListController.php',
537+
'ManiphestSearchIndexer' => 'applications/maniphest/search/ManiphestSearchIndexer.php',
536538
'ManiphestSubpriorityController' => 'applications/maniphest/controller/ManiphestSubpriorityController.php',
537539
'ManiphestTask' => 'applications/maniphest/storage/ManiphestTask.php',
538540
'ManiphestTaskAuxiliaryStorage' => 'applications/maniphest/storage/ManiphestTaskAuxiliaryStorage.php',
@@ -1052,6 +1054,7 @@
10521054
'PhabricatorRepositoryCommitMessageParserWorker' => 'applications/repository/worker/commitmessageparser/PhabricatorRepositoryCommitMessageParserWorker.php',
10531055
'PhabricatorRepositoryCommitOwnersWorker' => 'applications/repository/worker/PhabricatorRepositoryCommitOwnersWorker.php',
10541056
'PhabricatorRepositoryCommitParserWorker' => 'applications/repository/worker/PhabricatorRepositoryCommitParserWorker.php',
1057+
'PhabricatorRepositoryCommitSearchIndexer' => 'applications/repository/search/PhabricatorRepositoryCommitSearchIndexer.php',
10551058
'PhabricatorRepositoryController' => 'applications/repository/controller/PhabricatorRepositoryController.php',
10561059
'PhabricatorRepositoryCreateController' => 'applications/repository/controller/PhabricatorRepositoryCreateController.php',
10571060
'PhabricatorRepositoryDAO' => 'applications/repository/storage/PhabricatorRepositoryDAO.php',
@@ -1084,28 +1087,25 @@
10841087
'PhabricatorSearchAbstractDocument' => 'applications/search/index/PhabricatorSearchAbstractDocument.php',
10851088
'PhabricatorSearchAttachController' => 'applications/search/controller/PhabricatorSearchAttachController.php',
10861089
'PhabricatorSearchBaseController' => 'applications/search/controller/PhabricatorSearchBaseController.php',
1087-
'PhabricatorSearchCommitIndexer' => 'applications/search/index/indexer/PhabricatorSearchCommitIndexer.php',
10881090
'PhabricatorSearchController' => 'applications/search/controller/PhabricatorSearchController.php',
10891091
'PhabricatorSearchDAO' => 'applications/search/storage/PhabricatorSearchDAO.php',
1090-
'PhabricatorSearchDifferentialIndexer' => 'applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php',
10911092
'PhabricatorSearchDocument' => 'applications/search/storage/document/PhabricatorSearchDocument.php',
10921093
'PhabricatorSearchDocumentField' => 'applications/search/storage/document/PhabricatorSearchDocumentField.php',
1093-
'PhabricatorSearchDocumentIndexer' => 'applications/search/index/indexer/PhabricatorSearchDocumentIndexer.php',
1094+
'PhabricatorSearchDocumentIndexer' => 'applications/search/index/PhabricatorSearchDocumentIndexer.php',
10941095
'PhabricatorSearchDocumentRelationship' => 'applications/search/storage/document/PhabricatorSearchDocumentRelationship.php',
10951096
'PhabricatorSearchEngine' => 'applications/search/engine/PhabricatorSearchEngine.php',
10961097
'PhabricatorSearchEngineElastic' => 'applications/search/engine/PhabricatorSearchEngineElastic.php',
10971098
'PhabricatorSearchEngineMySQL' => 'applications/search/engine/PhabricatorSearchEngineMySQL.php',
10981099
'PhabricatorSearchEngineSelector' => 'applications/search/selector/PhabricatorSearchEngineSelector.php',
10991100
'PhabricatorSearchField' => 'applications/search/constants/PhabricatorSearchField.php',
1100-
'PhabricatorSearchManiphestIndexer' => 'applications/search/index/indexer/PhabricatorSearchManiphestIndexer.php',
1101-
'PhabricatorSearchPhrictionIndexer' => 'applications/search/index/indexer/PhabricatorSearchPhrictionIndexer.php',
1102-
'PhabricatorSearchPonderIndexer' => 'applications/ponder/search/PhabricatorSearchPonderIndexer.php',
1101+
'PhabricatorSearchIndexer' => 'applications/search/index/PhabricatorSearchIndexer.php',
1102+
'PhabricatorSearchManagementIndexWorkflow' => 'applications/search/management/PhabricatorSearchManagementIndexWorkflow.php',
1103+
'PhabricatorSearchManagementWorkflow' => 'applications/search/management/PhabricatorSearchManagementWorkflow.php',
11031104
'PhabricatorSearchQuery' => 'applications/search/storage/PhabricatorSearchQuery.php',
11041105
'PhabricatorSearchRelationship' => 'applications/search/constants/PhabricatorSearchRelationship.php',
11051106
'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php',
11061107
'PhabricatorSearchScope' => 'applications/search/constants/PhabricatorSearchScope.php',
11071108
'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php',
1108-
'PhabricatorSearchUserIndexer' => 'applications/search/index/indexer/PhabricatorSearchUserIndexer.php',
11091109
'PhabricatorSettingsAdjustController' => 'applications/settings/controller/PhabricatorSettingsAdjustController.php',
11101110
'PhabricatorSettingsMainController' => 'applications/settings/controller/PhabricatorSettingsMainController.php',
11111111
'PhabricatorSettingsPanel' => 'applications/settings/panel/PhabricatorSettingsPanel.php',
@@ -1191,6 +1191,7 @@
11911191
'PhabricatorUserPreferences' => 'applications/settings/storage/PhabricatorUserPreferences.php',
11921192
'PhabricatorUserProfile' => 'applications/people/storage/PhabricatorUserProfile.php',
11931193
'PhabricatorUserSSHKey' => 'applications/settings/storage/PhabricatorUserSSHKey.php',
1194+
'PhabricatorUserSearchIndexer' => 'applications/people/search/PhabricatorUserSearchIndexer.php',
11941195
'PhabricatorUserStatus' => 'applications/people/storage/PhabricatorUserStatus.php',
11951196
'PhabricatorUserStatusInvalidEpochException' => 'applications/people/exception/PhabricatorUserStatusInvalidEpochException.php',
11961197
'PhabricatorUserStatusOverlapException' => 'applications/people/exception/PhabricatorUserStatusOverlapException.php',
@@ -1256,7 +1257,6 @@
12561257
'PholioController' => 'applications/pholio/controller/PholioController.php',
12571258
'PholioDAO' => 'applications/pholio/storage/PholioDAO.php',
12581259
'PholioImage' => 'applications/pholio/storage/PholioImage.php',
1259-
'PholioIndexer' => 'applications/pholio/indexer/PholioIndexer.php',
12601260
'PholioMock' => 'applications/pholio/storage/PholioMock.php',
12611261
'PholioMockCommentController' => 'applications/pholio/controller/PholioMockCommentController.php',
12621262
'PholioMockEditController' => 'applications/pholio/controller/PholioMockEditController.php',
@@ -1265,6 +1265,7 @@
12651265
'PholioMockQuery' => 'applications/pholio/query/PholioMockQuery.php',
12661266
'PholioMockViewController' => 'applications/pholio/controller/PholioMockViewController.php',
12671267
'PholioReplyHandler' => 'applications/pholio/mail/PholioReplyHandler.php',
1268+
'PholioSearchIndexer' => 'applications/pholio/indexer/PholioSearchIndexer.php',
12681269
'PholioTransaction' => 'applications/pholio/storage/PholioTransaction.php',
12691270
'PholioTransactionComment' => 'applications/pholio/storage/PholioTransactionComment.php',
12701271
'PholioTransactionQuery' => 'applications/pholio/query/PholioTransactionQuery.php',
@@ -1291,6 +1292,7 @@
12911292
'PhrictionHistoryController' => 'applications/phriction/controller/PhrictionHistoryController.php',
12921293
'PhrictionListController' => 'applications/phriction/controller/PhrictionListController.php',
12931294
'PhrictionNewController' => 'applications/phriction/controller/PhrictionNewController.php',
1295+
'PhrictionSearchIndexer' => 'applications/phriction/search/PhrictionSearchIndexer.php',
12941296
'PonderAddAnswerView' => 'applications/ponder/view/PonderAddAnswerView.php',
12951297
'PonderAddCommentView' => 'applications/ponder/view/PonderAddCommentView.php',
12961298
'PonderAnswer' => 'applications/ponder/storage/PonderAnswer.php',
@@ -1324,6 +1326,7 @@
13241326
'PonderQuestionViewController' => 'applications/ponder/controller/PonderQuestionViewController.php',
13251327
'PonderReplyHandler' => 'applications/ponder/PonderReplyHandler.php',
13261328
'PonderRuleQuestion' => 'infrastructure/markup/rule/PonderRuleQuestion.php',
1329+
'PonderSearchIndexer' => 'applications/ponder/search/PonderSearchIndexer.php',
13271330
'PonderUserProfileView' => 'applications/ponder/view/PonderUserProfileView.php',
13281331
'PonderVotableInterface' => 'applications/ponder/storage/PonderVotableInterface.php',
13291332
'PonderVotableView' => 'applications/ponder/view/PonderVotableView.php',
@@ -1631,6 +1634,7 @@
16311634
'DifferentialRevisionStatusFieldSpecification' => 'DifferentialFieldSpecification',
16321635
'DifferentialRevisionUpdateHistoryView' => 'AphrontView',
16331636
'DifferentialRevisionViewController' => 'DifferentialController',
1637+
'DifferentialSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
16341638
'DifferentialSubscribeController' => 'DifferentialController',
16351639
'DifferentialSummaryFieldSpecification' => 'DifferentialFreeformFieldSpecification',
16361640
'DifferentialTestPlanFieldSpecification' => 'DifferentialFieldSpecification',
@@ -1815,6 +1819,7 @@
18151819
'ManiphestSavedQueryDeleteController' => 'ManiphestController',
18161820
'ManiphestSavedQueryEditController' => 'ManiphestController',
18171821
'ManiphestSavedQueryListController' => 'ManiphestController',
1822+
'ManiphestSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
18181823
'ManiphestSubpriorityController' => 'ManiphestController',
18191824
'ManiphestTask' =>
18201825
array(
@@ -2324,6 +2329,7 @@
23242329
'PhabricatorRepositoryCommitMessageParserWorker' => 'PhabricatorRepositoryCommitParserWorker',
23252330
'PhabricatorRepositoryCommitOwnersWorker' => 'PhabricatorRepositoryCommitParserWorker',
23262331
'PhabricatorRepositoryCommitParserWorker' => 'PhabricatorWorker',
2332+
'PhabricatorRepositoryCommitSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
23272333
'PhabricatorRepositoryController' => 'PhabricatorController',
23282334
'PhabricatorRepositoryCreateController' => 'PhabricatorRepositoryController',
23292335
'PhabricatorRepositoryDAO' => 'PhabricatorLiskDAO',
@@ -2351,22 +2357,18 @@
23512357
'PhabricatorSSHWorkflow' => 'PhutilArgumentWorkflow',
23522358
'PhabricatorSearchAttachController' => 'PhabricatorSearchBaseController',
23532359
'PhabricatorSearchBaseController' => 'PhabricatorController',
2354-
'PhabricatorSearchCommitIndexer' => 'PhabricatorSearchDocumentIndexer',
23552360
'PhabricatorSearchController' => 'PhabricatorSearchBaseController',
23562361
'PhabricatorSearchDAO' => 'PhabricatorLiskDAO',
2357-
'PhabricatorSearchDifferentialIndexer' => 'PhabricatorSearchDocumentIndexer',
23582362
'PhabricatorSearchDocument' => 'PhabricatorSearchDAO',
23592363
'PhabricatorSearchDocumentField' => 'PhabricatorSearchDAO',
23602364
'PhabricatorSearchDocumentRelationship' => 'PhabricatorSearchDAO',
23612365
'PhabricatorSearchEngineElastic' => 'PhabricatorSearchEngine',
23622366
'PhabricatorSearchEngineMySQL' => 'PhabricatorSearchEngine',
2363-
'PhabricatorSearchManiphestIndexer' => 'PhabricatorSearchDocumentIndexer',
2364-
'PhabricatorSearchPhrictionIndexer' => 'PhabricatorSearchDocumentIndexer',
2365-
'PhabricatorSearchPonderIndexer' => 'PhabricatorSearchDocumentIndexer',
2367+
'PhabricatorSearchManagementIndexWorkflow' => 'PhabricatorSearchManagementWorkflow',
2368+
'PhabricatorSearchManagementWorkflow' => 'PhutilArgumentWorkflow',
23662369
'PhabricatorSearchQuery' => 'PhabricatorSearchDAO',
23672370
'PhabricatorSearchResultView' => 'AphrontView',
23682371
'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController',
2369-
'PhabricatorSearchUserIndexer' => 'PhabricatorSearchDocumentIndexer',
23702372
'PhabricatorSettingsAdjustController' => 'PhabricatorController',
23712373
'PhabricatorSettingsMainController' => 'PhabricatorController',
23722374
'PhabricatorSettingsPanelAccount' => 'PhabricatorSettingsPanel',
@@ -2444,6 +2446,7 @@
24442446
'PhabricatorUserPreferences' => 'PhabricatorUserDAO',
24452447
'PhabricatorUserProfile' => 'PhabricatorUserDAO',
24462448
'PhabricatorUserSSHKey' => 'PhabricatorUserDAO',
2449+
'PhabricatorUserSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
24472450
'PhabricatorUserStatus' => 'PhabricatorUserDAO',
24482451
'PhabricatorUserStatusInvalidEpochException' => 'Exception',
24492452
'PhabricatorUserStatusOverlapException' => 'Exception',
@@ -2520,7 +2523,6 @@
25202523
0 => 'PholioDAO',
25212524
1 => 'PhabricatorMarkupInterface',
25222525
),
2523-
'PholioIndexer' => 'PhabricatorSearchDocumentIndexer',
25242526
'PholioMock' =>
25252527
array(
25262528
0 => 'PholioDAO',
@@ -2535,6 +2537,7 @@
25352537
'PholioMockQuery' => 'PhabricatorCursorPagedPolicyAwareQuery',
25362538
'PholioMockViewController' => 'PholioController',
25372539
'PholioReplyHandler' => 'PhabricatorMailReplyHandler',
2540+
'PholioSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
25382541
'PholioTransaction' => 'PhabricatorApplicationTransaction',
25392542
'PholioTransactionComment' => 'PhabricatorApplicationTransactionComment',
25402543
'PholioTransactionQuery' => 'PhabricatorApplicationTransactionQuery',
@@ -2564,6 +2567,7 @@
25642567
'PhrictionHistoryController' => 'PhrictionController',
25652568
'PhrictionListController' => 'PhrictionController',
25662569
'PhrictionNewController' => 'PhrictionController',
2570+
'PhrictionSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
25672571
'PonderAddAnswerView' => 'AphrontView',
25682572
'PonderAddCommentView' => 'AphrontView',
25692573
'PonderAnswer' =>
@@ -2611,6 +2615,7 @@
26112615
'PonderQuestionViewController' => 'PonderController',
26122616
'PonderReplyHandler' => 'PhabricatorMailReplyHandler',
26132617
'PonderRuleQuestion' => 'PhabricatorRemarkupRuleObjectName',
2618+
'PonderSearchIndexer' => 'PhabricatorSearchDocumentIndexer',
26142619
'PonderUserProfileView' => 'AphrontView',
26152620
'PonderVotableView' => 'AphrontView',
26162621
'PonderVoteEditor' => 'PhabricatorEditor',

src/applications/audit/editor/PhabricatorAuditCommentEditor.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,10 @@ public function addComment(PhabricatorAuditComment $comment) {
289289

290290
$feed_phids = array_diff($requests_phids, $feed_dont_publish_phids);
291291
$this->publishFeedStory($comment, $feed_phids);
292-
PhabricatorSearchCommitIndexer::indexCommit($commit);
292+
293+
id(new PhabricatorSearchIndexer())
294+
->indexDocumentByPHID($commit->getPHID());
295+
293296
$this->sendMail($comment, $other_comments, $inline_comments, $requests);
294297
}
295298

src/applications/differential/editor/DifferentialCommentEditor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,8 @@ public function save() {
598598
->setMailRecipientPHIDs($mailed_phids)
599599
->publish();
600600

601-
// TODO: Move to workers
602-
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
601+
id(new PhabricatorSearchIndexer())
602+
->indexDocumentByPHID($revision->getPHID());
603603

604604
return $comment;
605605
}

src/applications/differential/editor/DifferentialRevisionEditor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -489,8 +489,8 @@ public function save() {
489489
->setMailRecipientPHIDs($mailed_phids)
490490
->publish();
491491

492-
// TODO: Move this into a worker task thing.
493-
PhabricatorSearchDifferentialIndexer::indexRevision($revision);
492+
id(new PhabricatorSearchIndexer())
493+
->indexDocumentByPHID($revision->getPHID());
494494
}
495495

496496
public static function addCCAndUpdateRevision(

src/applications/search/index/indexer/PhabricatorSearchDifferentialIndexer.php renamed to src/applications/differential/search/DifferentialSearchIndexer.php

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,18 @@
11
<?php
22

33
/**
4-
* @group search
4+
* @group differential
55
*/
6-
final class PhabricatorSearchDifferentialIndexer
6+
final class DifferentialSearchIndexer
77
extends PhabricatorSearchDocumentIndexer {
88

9-
public static function indexRevision(DifferentialRevision $rev) {
9+
public function getIndexableObject() {
10+
return new DifferentialRevision();
11+
}
12+
13+
protected function buildAbstractDocumentByPHID($phid) {
14+
$rev = $this->loadDocumentByPHID($phid);
15+
1016
$doc = new PhabricatorSearchAbstractDocument();
1117
$doc->setPHID($rev->getPHID());
1218
$doc->setDocumentType(PhabricatorPHIDConstants::PHID_TYPE_DREV);
@@ -108,6 +114,6 @@ public static function indexRevision(DifferentialRevision $rev) {
108114
$rev->getDateModified()); // Bogus timestamp.
109115
}
110116

111-
self::reindexAbstractDocument($doc);
117+
return $doc;
112118
}
113119
}

src/applications/diffusion/controller/DiffusionCommitEditController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ public function processRequest() {
4444
}
4545
$editor->save();
4646

47-
PhabricatorSearchCommitIndexer::indexCommit($commit);
47+
id(new PhabricatorSearchIndexer())
48+
->indexDocumentByPHID($commit->getPHID());
4849

4950
return id(new AphrontRedirectResponse())
5051
->setURI('/r'.$callsign.$commit->getCommitIdentifier());

src/applications/maniphest/editor/ManiphestTransactionEditor.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@ public function applyTransactions(ManiphestTask $task, array $transactions) {
199199
$transactions,
200200
$mail->buildRecipientList());
201201

202-
// TODO: Do this offline via workers
203-
PhabricatorSearchManiphestIndexer::indexTask($task);
204-
202+
id(new PhabricatorSearchIndexer())
203+
->indexDocumentByPHID($task->getPHID());
205204
}
206205

207206
protected function getSubjectPrefix() {

0 commit comments

Comments
 (0)