@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Perform search indexing in the worker queue and respect `bin/search index --background`

Summary: Fixes T3857. Earlier work made this trivial and just left product questions, which I've answered by requiring the daemons to run on reasonable installs.

Test Plan: Ran `bin/search index` and `bin/search index --background`. Observed indexes write in the former case and tasks queue in the latter case. Commented with a unique string on a revision and searched for it a moment later, got exactly one result (that revision), verifying that reindexing works correctly.

Reviewers: btrahan

Reviewed By: btrahan

CC: aran

Maniphest Tasks: T3857

Differential Revision: https://secure.phabricator.com/D7966

+49 -23
+2
src/__phutil_library_map__.php
··· 1900 1900 'PhabricatorSearchResultView' => 'applications/search/view/PhabricatorSearchResultView.php', 1901 1901 'PhabricatorSearchScope' => 'applications/search/constants/PhabricatorSearchScope.php', 1902 1902 'PhabricatorSearchSelectController' => 'applications/search/controller/PhabricatorSearchSelectController.php', 1903 + 'PhabricatorSearchWorker' => 'applications/search/worker/PhabricatorSearchWorker.php', 1903 1904 'PhabricatorSecurityConfigOptions' => 'applications/config/option/PhabricatorSecurityConfigOptions.php', 1904 1905 'PhabricatorSendGridConfigOptions' => 'applications/config/option/PhabricatorSendGridConfigOptions.php', 1905 1906 'PhabricatorSettingsAdjustController' => 'applications/settings/controller/PhabricatorSettingsAdjustController.php', ··· 4543 4544 'PhabricatorSearchQuery' => 'PhabricatorSearchDAO', 4544 4545 'PhabricatorSearchResultView' => 'AphrontView', 4545 4546 'PhabricatorSearchSelectController' => 'PhabricatorSearchBaseController', 4547 + 'PhabricatorSearchWorker' => 'PhabricatorWorker', 4546 4548 'PhabricatorSecurityConfigOptions' => 'PhabricatorApplicationConfigOptions', 4547 4549 'PhabricatorSendGridConfigOptions' => 'PhabricatorApplicationConfigOptions', 4548 4550 'PhabricatorSettingsAdjustController' => 'PhabricatorController',
+1 -1
src/applications/audit/editor/PhabricatorAuditCommentEditor.php
··· 302 302 $this->publishFeedStory($comment, $feed_phids); 303 303 304 304 id(new PhabricatorSearchIndexer()) 305 - ->indexDocumentByPHID($commit->getPHID()); 305 + ->queueDocumentForIndexing($commit->getPHID()); 306 306 307 307 if (!$this->noEmail) { 308 308 $this->sendMail($comment, $other_comments, $inline_comments, $requests);
+1 -1
src/applications/differential/editor/DifferentialCommentEditor.php
··· 700 700 ->publish(); 701 701 702 702 id(new PhabricatorSearchIndexer()) 703 - ->indexDocumentByPHID($revision->getPHID()); 703 + ->queueDocumentForIndexing($revision->getPHID()); 704 704 705 705 return $comment; 706 706 }
+1 -1
src/applications/differential/editor/DifferentialRevisionEditor.php
··· 534 534 ->publish(); 535 535 536 536 id(new PhabricatorSearchIndexer()) 537 - ->indexDocumentByPHID($revision->getPHID()); 537 + ->queueDocumentForIndexing($revision->getPHID()); 538 538 } 539 539 540 540 public static function addCCAndUpdateRevision(
+1 -1
src/applications/diffusion/controller/DiffusionCommitEditController.php
··· 45 45 $editor->save(); 46 46 47 47 id(new PhabricatorSearchIndexer()) 48 - ->indexDocumentByPHID($commit->getPHID()); 48 + ->queueDocumentForIndexing($commit->getPHID()); 49 49 50 50 return id(new AphrontRedirectResponse()) 51 51 ->setURI('/r'.$callsign.$commit->getCommitIdentifier());
+1 -1
src/applications/people/storage/PhabricatorUser.php
··· 152 152 $this->updateNameTokens(); 153 153 154 154 id(new PhabricatorSearchIndexer()) 155 - ->indexDocumentByPHID($this->getPHID()); 155 + ->queueDocumentForIndexing($this->getPHID()); 156 156 157 157 return $result; 158 158 }
+1 -1
src/applications/phriction/editor/PhrictionDocumentEditor.php
··· 213 213 $document->attachContent($new_content); 214 214 215 215 id(new PhabricatorSearchIndexer()) 216 - ->indexDocumentByPHID($document->getPHID()); 216 + ->queueDocumentForIndexing($document->getPHID()); 217 217 218 218 // Stub out empty parent documents if they don't exist 219 219 $ancestral_slugs = PhabricatorSlug::getAncestry($document->getSlug());
+1 -1
src/applications/project/editor/PhabricatorProjectEditor.php
··· 168 168 } 169 169 170 170 id(new PhabricatorSearchIndexer()) 171 - ->indexDocumentByPHID($project->getPHID()); 171 + ->queueDocumentForIndexing($project->getPHID()); 172 172 173 173 return $this; 174 174 }
+1 -1
src/applications/repository/worker/commitchangeparser/PhabricatorRepositoryCommitChangeParserWorker.php
··· 87 87 PhabricatorRepositoryCommit::IMPORTED_CHANGE); 88 88 89 89 id(new PhabricatorSearchIndexer()) 90 - ->indexDocumentByPHID($commit->getPHID()); 90 + ->queueDocumentForIndexing($commit->getPHID()); 91 91 92 92 PhabricatorOwnersPackagePathValidator::updateOwnersPackagePaths($commit); 93 93 if ($this->shouldQueueFollowupTasks()) {
+8 -3
src/applications/search/index/PhabricatorSearchIndexer.php
··· 1 1 <?php 2 2 3 - /** 4 - * @group search 5 - */ 6 3 final class PhabricatorSearchIndexer { 4 + 5 + public function queueDocumentForIndexing($phid) { 6 + PhabricatorWorker::scheduleTask( 7 + 'PhabricatorSearchWorker', 8 + array( 9 + 'documentPHID' => $phid, 10 + )); 11 + } 7 12 8 13 public function indexDocumentByPHID($phid) { 9 14 $doc_indexer_symbols = id(new PhutilSymbolLoader())
+17 -11
src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
··· 28 28 array( 29 29 'name' => 'background', 30 30 'help' => 'Instead of indexing in this process, queue tasks for '. 31 - 'the daemons. This is better if you are indexing a lot '. 32 - 'of stuff, but less helpful for debugging.', 33 - ), 34 - array( 35 - 'name' => 'foreground', 36 - 'help' => 'Index in this process, even if there are many objects '. 37 - 'to index. This is helpful for debugging.', 31 + 'the daemons. This can improve performance, but makes '. 32 + 'it more difficult to debug search indexing.', 38 33 ), 39 34 array( 40 35 'name' => 'objects', ··· 50 45 $is_type = $args->getArg('type'); 51 46 52 47 $obj_names = $args->getArg('objects'); 53 - 54 48 55 49 if ($obj_names && ($is_all || $is_type)) { 56 50 throw new PhutilArgumentUsageException( ··· 72 66 "Nothing to index!"); 73 67 } 74 68 69 + if ($args->getArg('background')) { 70 + $is_background = true; 71 + } else { 72 + PhabricatorWorker::setRunAllTasksInProcess(true); 73 + $is_background = false; 74 + } 75 + 75 76 $groups = phid_group_by_type($phids); 76 77 foreach ($groups as $group_type => $group) { 77 78 $console->writeOut( 79 + "%s\n", 78 80 pht( 79 81 "Indexing %d object(s) of type %s.", 80 82 count($group), 81 - $group_type)."\n"); 83 + $group_type)); 82 84 } 83 85 84 86 $indexer = new PhabricatorSearchIndexer(); 85 87 foreach ($phids as $phid) { 86 - $indexer->indexDocumentByPHID($phid); 87 - $console->writeOut(pht("Indexing '%s'...\n", $phid)); 88 + if ($is_background) { 89 + $console->writeOut("%s\n", pht("Queueing '%s'...", $phid)); 90 + } else { 91 + $console->writeOut("%s\n", pht("Indexing '%s'...", $phid)); 92 + } 93 + $indexer->queueDocumentForIndexing($phid); 88 94 } 89 95 90 96 $console->writeOut("Done.\n");
+13
src/applications/search/worker/PhabricatorSearchWorker.php
··· 1 + <?php 2 + 3 + final class PhabricatorSearchWorker extends PhabricatorWorker { 4 + 5 + public function doWork() { 6 + $data = $this->getTaskData(); 7 + $phid = idx($data, 'documentPHID'); 8 + 9 + id(new PhabricatorSearchIndexer()) 10 + ->indexDocumentByPHID($phid); 11 + } 12 + 13 + }
+1 -1
src/applications/transactions/editor/PhabricatorApplicationTransactionEditor.php
··· 533 533 534 534 if ($this->supportsSearch()) { 535 535 id(new PhabricatorSearchIndexer()) 536 - ->indexDocumentByPHID($object->getPHID()); 536 + ->queueDocumentForIndexing($object->getPHID()); 537 537 } 538 538 539 539 if ($this->supportsFeed()) {