Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14396273
D7966.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
9 KB
Referenced Files
None
Subscribers
None
D7966.diff
View Options
Index: src/__phutil_library_map__.php
===================================================================
--- src/__phutil_library_map__.php
+++ src/__phutil_library_map__.php
@@ -1900,6 +1900,7 @@
'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php',
'PhabricatorSearchScope' => 'applications/search/constants/PhabricatorSearchScope.php',
'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php',
+ 'PhabricatorSearchWorker' => 'applications/search/worker/PhabricatorSearchWorker.php',
'PhabricatorSecurityConfigOptions' => 'applications/config/option/PhabricatorSecurityConfigOptions.php',
'PhabricatorSendGridConfigOptions' => 'applications/config/option/PhabricatorSendGridConfigOptions.php',
'PhabricatorSettingsAdjustController' => 'applications/settings/controller/PhabricatorSettingsAdjustController.php',
@@ -4543,6 +4544,7 @@
'PhabricatorSearchQuery' => 'PhabricatorSearchDAO',
'PhabricatorSearchResultView' => 'AphrontView',
'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController',
+ 'PhabricatorSearchWorker' => 'PhabricatorWorker',
'PhabricatorSecurityConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorSendGridConfigOptions' => 'PhabricatorApplicationConfigOptions',
'PhabricatorSettingsAdjustController' => 'PhabricatorController',
Index: src/applications/audit/editor/PhabricatorAuditCommentEditor.php
===================================================================
--- src/applications/audit/editor/PhabricatorAuditCommentEditor.php
+++ src/applications/audit/editor/PhabricatorAuditCommentEditor.php
@@ -302,7 +302,7 @@
$this->publishFeedStory($comment, $feed_phids);
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($commit->getPHID());
+ ->queueDocumentForIndexing($commit->getPHID());
if (!$this->noEmail) {
$this->sendMail($comment, $other_comments, $inline_comments, $requests);
Index: src/applications/differential/editor/DifferentialCommentEditor.php
===================================================================
--- src/applications/differential/editor/DifferentialCommentEditor.php
+++ src/applications/differential/editor/DifferentialCommentEditor.php
@@ -700,7 +700,7 @@
->publish();
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($revision->getPHID());
+ ->queueDocumentForIndexing($revision->getPHID());
return $comment;
}
Index: src/applications/differential/editor/DifferentialRevisionEditor.php
===================================================================
--- src/applications/differential/editor/DifferentialRevisionEditor.php
+++ src/applications/differential/editor/DifferentialRevisionEditor.php
@@ -534,7 +534,7 @@
->publish();
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($revision->getPHID());
+ ->queueDocumentForIndexing($revision->getPHID());
}
public static function addCCAndUpdateRevision(
Index: src/applications/diffusion/controller/DiffusionCommitEditController.php
===================================================================
--- src/applications/diffusion/controller/DiffusionCommitEditController.php
+++ src/applications/diffusion/controller/DiffusionCommitEditController.php
@@ -45,7 +45,7 @@
$editor->save();
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($commit->getPHID());
+ ->queueDocumentForIndexing($commit->getPHID());
return id(new AphrontRedirectResponse())
->setURI('/r'.$callsign.$commit->getCommitIdentifier());
Index: src/applications/people/storage/PhabricatorUser.php
===================================================================
--- src/applications/people/storage/PhabricatorUser.php
+++ src/applications/people/storage/PhabricatorUser.php
@@ -152,7 +152,7 @@
$this->updateNameTokens();
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($this->getPHID());
+ ->queueDocumentForIndexing($this->getPHID());
return $result;
}
Index: src/applications/phriction/editor/PhrictionDocumentEditor.php
===================================================================
--- src/applications/phriction/editor/PhrictionDocumentEditor.php
+++ src/applications/phriction/editor/PhrictionDocumentEditor.php
@@ -213,7 +213,7 @@
$document->attachContent($new_content);
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($document->getPHID());
+ ->queueDocumentForIndexing($document->getPHID());
// Stub out empty parent documents if they don't exist
$ancestral_slugs = PhabricatorSlug::getAncestry($document->getSlug());
Index: src/applications/project/editor/PhabricatorProjectEditor.php
===================================================================
--- src/applications/project/editor/PhabricatorProjectEditor.php
+++ src/applications/project/editor/PhabricatorProjectEditor.php
@@ -168,7 +168,7 @@
}
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($project->getPHID());
+ ->queueDocumentForIndexing($project->getPHID());
return $this;
}
Index: src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
===================================================================
--- src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
+++ src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
@@ -87,7 +87,7 @@
PhabricatorRepositoryCommit::IMPORTED_CHANGE);
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($commit->getPHID());
+ ->queueDocumentForIndexing($commit->getPHID());
PhabricatorOwnersPackagePathValidator::updateOwnersPackagePaths($commit);
if ($this->shouldQueueFollowupTasks()) {
Index: src/applications/search/index/PhabricatorSearchIndexer.php
===================================================================
--- src/applications/search/index/PhabricatorSearchIndexer.php
+++ src/applications/search/index/PhabricatorSearchIndexer.php
@@ -1,10 +1,15 @@
<?php
-/**
- * @group search
- */
final class PhabricatorSearchIndexer {
+ public function queueDocumentForIndexing($phid) {
+ PhabricatorWorker::scheduleTask(
+ 'PhabricatorSearchWorker',
+ array(
+ 'documentPHID' => $phid,
+ ));
+ }
+
public function indexDocumentByPHID($phid) {
$doc_indexer_symbols = id(new PhutilSymbolLoader())
->setAncestorClass('PhabricatorSearchDocumentIndexer')
Index: src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
===================================================================
--- src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
+++ src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
@@ -28,13 +28,8 @@
array(
'name' => 'background',
'help' => 'Instead of indexing in this process, queue tasks for '.
- 'the daemons. This is better if you are indexing a lot '.
- 'of stuff, but less helpful for debugging.',
- ),
- array(
- 'name' => 'foreground',
- 'help' => 'Index in this process, even if there are many objects '.
- 'to index. This is helpful for debugging.',
+ 'the daemons. This can improve performance, but makes '.
+ 'it more difficult to debug search indexing.',
),
array(
'name' => 'objects',
@@ -51,7 +46,6 @@
$obj_names = $args->getArg('objects');
-
if ($obj_names && ($is_all || $is_type)) {
throw new PhutilArgumentUsageException(
"You can not name objects to index alongside the '--all' or '--type' ".
@@ -72,19 +66,31 @@
"Nothing to index!");
}
+ if ($args->getArg('background')) {
+ $is_background = true;
+ } else {
+ PhabricatorWorker::setRunAllTasksInProcess(true);
+ $is_background = false;
+ }
+
$groups = phid_group_by_type($phids);
foreach ($groups as $group_type => $group) {
$console->writeOut(
+ "%s\n",
pht(
"Indexing %d object(s) of type %s.",
count($group),
- $group_type)."\n");
+ $group_type));
}
$indexer = new PhabricatorSearchIndexer();
foreach ($phids as $phid) {
- $indexer->indexDocumentByPHID($phid);
- $console->writeOut(pht("Indexing '%s'...\n", $phid));
+ if ($is_background) {
+ $console->writeOut("%s\n", pht("Queueing '%s'...", $phid));
+ } else {
+ $console->writeOut("%s\n", pht("Indexing '%s'...", $phid));
+ }
+ $indexer->queueDocumentForIndexing($phid);
}
$console->writeOut("Done.\n");
Index: src/applications/search/worker/PhabricatorSearchWorker.php
===================================================================
--- /dev/null
+++ src/applications/search/worker/PhabricatorSearchWorker.php
@@ -0,0 +1,13 @@
+<?php
+
+final class PhabricatorSearchWorker extends PhabricatorWorker {
+
+ public function doWork() {
+ $data = $this->getTaskData();
+ $phid = idx($data, 'documentPHID');
+
+ id(new PhabricatorSearchIndexer())
+ ->indexDocumentByPHID($phid);
+ }
+
+}
Index: src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
===================================================================
--- src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
+++ src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
@@ -533,7 +533,7 @@
if ($this->supportsSearch()) {
id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($object->getPHID());
+ ->queueDocumentForIndexing($object->getPHID());
}
if ($this->supportsFeed()) {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Dec 23, 7:04 AM (17 h, 53 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6920818
Default Alt Text
D7966.diff (9 KB)
Attached To
Mode
D7966: Perform search indexing in the worker queue and respect `bin/search index --background`
Attached
Detach File
Event Timeline
Log In to Comment