Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14004325
D13111.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D13111.diff
View Options
diff --git a/src/applications/search/engine/PhabricatorElasticSearchEngine.php b/src/applications/search/engine/PhabricatorElasticSearchEngine.php
--- a/src/applications/search/engine/PhabricatorElasticSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorElasticSearchEngine.php
@@ -121,6 +121,18 @@
return $doc;
}
+ public function removeDocument($phid) {
+ $type = phid_get_type($phid);
+
+ try {
+ $this->executeRequest("/{$type}/{$phid}/", array(), 'DELETE');
+ } catch (HTTPFutureResponseStatus $ex) {
+ if ($ex->getStatusCode() != 404) {
+ throw $ex;
+ }
+ }
+ }
+
private function buildSpec(PhabricatorSavedQuery $query) {
$spec = array();
$filter = array();
diff --git a/src/applications/search/engine/PhabricatorMySQLSearchEngine.php b/src/applications/search/engine/PhabricatorMySQLSearchEngine.php
--- a/src/applications/search/engine/PhabricatorMySQLSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorMySQLSearchEngine.php
@@ -151,6 +151,30 @@
return $adoc;
}
+ public function removeDocument($phid) {
+ $table = new PhabricatorSearchDocument();
+ $conn_w = $table->establishConnection('w');
+
+ queryfx(
+ $conn_w,
+ 'DELETE FROM %T WHERE phid = %s',
+ $table->getTableName(),
+ $phid);
+
+ queryfx(
+ $conn_w,
+ 'DELETE FROM %T WHERE phid = %s',
+ id(new PhabricatorSearchDocumentField())->getTableName(),
+ $phid);
+
+ queryfx(
+ $conn_w,
+ 'DELETE FROM %T WHERE phid = %s OR relatedPHID = %s',
+ id(new PhabricatorSearchDocumentRelationship())->getTableName(),
+ $phid,
+ $phid);
+ }
+
public function executeSearch(PhabricatorSavedQuery $query) {
$where = array();
$join = array();
diff --git a/src/applications/search/engine/PhabricatorSearchEngine.php b/src/applications/search/engine/PhabricatorSearchEngine.php
--- a/src/applications/search/engine/PhabricatorSearchEngine.php
+++ b/src/applications/search/engine/PhabricatorSearchEngine.php
@@ -69,6 +69,14 @@
abstract public function reconstructDocument($phid);
/**
+ * Remove the document for a given PHID.
+ *
+ * @param phid Document PHID to remove.
+ * @return void
+ */
+ abstract public function removeDocument($phid);
+
+ /**
* Execute a search query.
*
* @param PhabricatorSavedQuery A query to execute.
diff --git a/src/applications/system/engine/PhabricatorDestructionEngine.php b/src/applications/system/engine/PhabricatorDestructionEngine.php
--- a/src/applications/system/engine/PhabricatorDestructionEngine.php
+++ b/src/applications/system/engine/PhabricatorDestructionEngine.php
@@ -67,7 +67,7 @@
$transcript->destroyObjectPermanently($this);
}
- // TODO: Remove stuff from search indexes?
+ $this->destroySearchIndexes($object_phid);
if ($object instanceof PhabricatorFlaggableInterface) {
$flags = id(new PhabricatorFlag())->loadAllWhere(
@@ -148,4 +148,12 @@
$object_phid);
}
+ private function destroySearchIndexes($object_phid) {
+ $engines = PhabricatorSearchEngine::loadActiveEngines();
+
+ foreach ($engines as $engine) {
+ $engine->removeDocument($object_phid);
+ }
+ }
+
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Oct 27, 6:32 PM (1 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
6718515
Default Alt Text
D13111.diff (3 KB)
Attached To
Mode
D13111: Remove search indexes upon object deletion
Attached
Detach File
Event Timeline
Log In to Comment