Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F15422969
D14174.id34244.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
4 KB
Referenced Files
None
Subscribers
None
D14174.id34244.diff
View Options
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
@@ -42,54 +42,36 @@
}
public function indexDocumentByPHID($phid, $context) {
- try {
- $this->setContext($context);
+ $this->setContext($context);
- $document = $this->buildAbstractDocumentByPHID($phid);
- if ($document === null) {
- // This indexer doesn't build a document index, so we're done.
- return $this;
- }
+ $document = $this->buildAbstractDocumentByPHID($phid);
+ if ($document === null) {
+ // This indexer doesn't build a document index, so we're done.
+ return $this;
+ }
- $object = $this->loadDocumentByPHID($phid);
+ $object = $this->loadDocumentByPHID($phid);
- // Automatically rebuild CustomField indexes if the object uses custom
- // fields.
- if ($object instanceof PhabricatorCustomFieldInterface) {
- $this->indexCustomFields($document, $object);
- }
+ // Automatically rebuild CustomField indexes if the object uses custom
+ // fields.
+ if ($object instanceof PhabricatorCustomFieldInterface) {
+ $this->indexCustomFields($document, $object);
+ }
- // Automatically rebuild subscriber indexes if the object is subscribable.
- if ($object instanceof PhabricatorSubscribableInterface) {
- $this->indexSubscribers($document);
- }
+ // Automatically rebuild subscriber indexes if the object is subscribable.
+ if ($object instanceof PhabricatorSubscribableInterface) {
+ $this->indexSubscribers($document);
+ }
- // Automatically build project relationships
- if ($object instanceof PhabricatorProjectInterface) {
- $this->indexProjects($document, $object);
- }
+ // Automatically build project relationships
+ if ($object instanceof PhabricatorProjectInterface) {
+ $this->indexProjects($document, $object);
+ }
- $engine = PhabricatorSearchEngine::loadEngine();
- try {
- $engine->reindexAbstractDocument($document);
- } catch (Exception $ex) {
- phlog(
- pht(
- 'Unable to index document %s with engine %s.',
- $document->getPHID(),
- get_class($engine)));
- phlog($ex);
- }
+ $engine = PhabricatorSearchEngine::loadEngine();
+ $engine->reindexAbstractDocument($document);
- $this->dispatchDidUpdateIndexEvent($phid, $document);
- } catch (Exception $ex) {
- phlog(
- pht(
- 'Unable to build document %s with indexer %s.',
- $phid,
- get_class($this)));
- phlog($ex);
- }
+ $this->dispatchDidUpdateIndexEvent($phid, $document);
return $this;
}
diff --git a/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php b/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
--- a/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
+++ b/src/applications/search/management/PhabricatorSearchManagementIndexWorkflow.php
@@ -93,13 +93,26 @@
$bar = id(new PhutilConsoleProgressBar())
->setTotal(count($phids));
+ $any_success = false;
$indexer = new PhabricatorSearchIndexer();
foreach ($phids as $phid) {
- $indexer->queueDocumentForIndexing($phid);
+ try {
+ $indexer->queueDocumentForIndexing($phid);
+ $any_success = true;
+ } catch (Exception $ex) {
+ phlog($ex);
+ }
+
$bar->update(1);
}
$bar->done();
+
+ if (!$any_success) {
+ throw new Exception(
+ pht('Failed to rebuild search index for any documents.'));
+ }
+
}
private function loadPHIDsByNames(array $names) {
diff --git a/src/applications/search/worker/PhabricatorSearchWorker.php b/src/applications/search/worker/PhabricatorSearchWorker.php
--- a/src/applications/search/worker/PhabricatorSearchWorker.php
+++ b/src/applications/search/worker/PhabricatorSearchWorker.php
@@ -8,8 +8,16 @@
$phid = idx($data, 'documentPHID');
$context = idx($data, 'context');
- id(new PhabricatorSearchIndexer())
- ->indexDocumentByPHID($phid, $context);
+ try {
+ id(new PhabricatorSearchIndexer())
+ ->indexDocumentByPHID($phid, $context);
+ } catch (Exception $ex) {
+ throw new PhabricatorWorkerPermanentFailureException(
+ pht(
+ 'Failed to update search index for document "%s": %s',
+ $phid,
+ $ex->getMessage()));
+ }
}
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 23, 11:42 AM (5 d, 4 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7223585
Default Alt Text
D14174.id34244.diff (4 KB)
Attached To
Mode
D14174: Refine error behavior of `bin/search index`
Attached
Detach File
Event Timeline
Log In to Comment