mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-19 12:00:55 +01:00
Remove TYPE_SEARCH_DIDUPDATEINDEX event
Summary: Ref T9979. This event had one weird callsite and no known third-party callers. It can be done more cleanly as an extension, now. This index is used to allow us to "Group By: Project" in Maniphest without joining into the Projects database. Test Plan: - Ran a query with "Group By: Project" in Maniphest. - Renamed project "Apples" to "Zebras". - Reloaded page. - UI properly moved "Zebras" tasks to the bottom of the list. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9979 Differential Revision: https://secure.phabricator.com/D14836
This commit is contained in:
parent
02f82c2af5
commit
aab1574e33
7 changed files with 27 additions and 82 deletions
|
@ -1294,9 +1294,9 @@ phutil_register_library_map(array(
|
|||
'ManiphestHovercardEventListener' => 'applications/maniphest/event/ManiphestHovercardEventListener.php',
|
||||
'ManiphestInfoConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestInfoConduitAPIMethod.php',
|
||||
'ManiphestNameIndex' => 'applications/maniphest/storage/ManiphestNameIndex.php',
|
||||
'ManiphestNameIndexEventListener' => 'applications/maniphest/event/ManiphestNameIndexEventListener.php',
|
||||
'ManiphestPriorityConfigOptionType' => 'applications/maniphest/config/ManiphestPriorityConfigOptionType.php',
|
||||
'ManiphestPriorityEmailCommand' => 'applications/maniphest/command/ManiphestPriorityEmailCommand.php',
|
||||
'ManiphestProjectNameFulltextEngineExtension' => 'applications/maniphest/engineextension/ManiphestProjectNameFulltextEngineExtension.php',
|
||||
'ManiphestQueryConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryConduitAPIMethod.php',
|
||||
'ManiphestQueryStatusesConduitAPIMethod' => 'applications/maniphest/conduit/ManiphestQueryStatusesConduitAPIMethod.php',
|
||||
'ManiphestRemarkupRule' => 'applications/maniphest/remarkup/ManiphestRemarkupRule.php',
|
||||
|
@ -5338,9 +5338,9 @@ phutil_register_library_map(array(
|
|||
'ManiphestHovercardEventListener' => 'PhabricatorEventListener',
|
||||
'ManiphestInfoConduitAPIMethod' => 'ManiphestConduitAPIMethod',
|
||||
'ManiphestNameIndex' => 'ManiphestDAO',
|
||||
'ManiphestNameIndexEventListener' => 'PhabricatorEventListener',
|
||||
'ManiphestPriorityConfigOptionType' => 'PhabricatorConfigJSONOptionType',
|
||||
'ManiphestPriorityEmailCommand' => 'ManiphestEmailCommand',
|
||||
'ManiphestProjectNameFulltextEngineExtension' => 'PhabricatorFulltextEngineExtension',
|
||||
'ManiphestQueryConduitAPIMethod' => 'ManiphestConduitAPIMethod',
|
||||
'ManiphestQueryStatusesConduitAPIMethod' => 'ManiphestConduitAPIMethod',
|
||||
'ManiphestRemarkupRule' => 'PhabricatorObjectRemarkupRule',
|
||||
|
|
|
@ -38,7 +38,6 @@ final class PhabricatorManiphestApplication extends PhabricatorApplication {
|
|||
|
||||
public function getEventListeners() {
|
||||
return array(
|
||||
new ManiphestNameIndexEventListener(),
|
||||
new ManiphestHovercardEventListener(),
|
||||
);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestProjectNameFulltextEngineExtension
|
||||
extends PhabricatorFulltextEngineExtension {
|
||||
|
||||
const EXTENSIONKEY = 'maniphest.project.name';
|
||||
|
||||
public function getExtensionName() {
|
||||
return pht('Maniphest Project Name Cache');
|
||||
}
|
||||
|
||||
public function shouldIndexFulltextObject($object) {
|
||||
return ($object instanceof PhabricatorProject);
|
||||
}
|
||||
|
||||
public function indexFulltextObject(
|
||||
$object,
|
||||
PhabricatorSearchAbstractDocument $document) {
|
||||
|
||||
ManiphestNameIndex::updateIndex(
|
||||
$object->getPHID(),
|
||||
$object->getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<?php
|
||||
|
||||
final class ManiphestNameIndexEventListener extends PhabricatorEventListener {
|
||||
|
||||
public function register() {
|
||||
$this->listen(PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX);
|
||||
}
|
||||
|
||||
public function handleEvent(PhutilEvent $event) {
|
||||
$phid = $event->getValue('phid');
|
||||
$type = phid_get_type($phid);
|
||||
|
||||
// For now, we only index projects.
|
||||
if ($type != PhabricatorProjectProjectPHIDType::TYPECONST) {
|
||||
return;
|
||||
}
|
||||
|
||||
$document = $event->getValue('document');
|
||||
|
||||
ManiphestNameIndex::updateIndex(
|
||||
$phid,
|
||||
$document->getDocumentTitle());
|
||||
}
|
||||
|
||||
}
|
|
@ -66,8 +66,6 @@ abstract class PhabricatorSearchDocumentIndexer extends Phobject {
|
|||
$engine = PhabricatorSearchEngine::loadEngine();
|
||||
$engine->reindexAbstractDocument($document);
|
||||
|
||||
$this->dispatchDidUpdateIndexEvent($phid, $document);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -99,19 +97,4 @@ abstract class PhabricatorSearchDocumentIndexer extends Phobject {
|
|||
}
|
||||
}
|
||||
|
||||
private function dispatchDidUpdateIndexEvent(
|
||||
$phid,
|
||||
PhabricatorSearchAbstractDocument $document) {
|
||||
|
||||
$event = new PhabricatorEvent(
|
||||
PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX,
|
||||
array(
|
||||
'phid' => $phid,
|
||||
'object' => $this->loadDocumentByPHID($phid),
|
||||
'document' => $document,
|
||||
));
|
||||
$event->setUser($this->getViewer());
|
||||
PhutilEventEngine::dispatchEvent($event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -188,41 +188,6 @@ Data available on this event:
|
|||
|
||||
Using @{class@libphutil:PhutilEmailAddress} may be helpful in parsing the query.
|
||||
|
||||
== Search: Did Update Index ==
|
||||
|
||||
The constant for this event is
|
||||
`PhabricatorEventType::TYPE_SEARCH_DIDUPDATEINDEX`.
|
||||
|
||||
This event is dispatched from the Search application's indexing engine, after
|
||||
it indexes a document. It allows you to publish search-like indexes into other
|
||||
systems.
|
||||
|
||||
Note that this event happens after the update is fully complete: you can not
|
||||
prevent or modify the update. Further, the event may fire significantly later
|
||||
in real time than the update, as indexing may occur in the background. You
|
||||
should use other events if you need guarantees about when the event executes.
|
||||
|
||||
Finally, this event may fire more than once for a single update. For example,
|
||||
if the search indexes are rebuilt, this event will fire on objects which have
|
||||
not actually changed.
|
||||
|
||||
So, good use cases for event listeners are:
|
||||
|
||||
- Updating secondary search indexes.
|
||||
|
||||
Bad use cases are:
|
||||
|
||||
- Editing the object or document.
|
||||
- Anything with side effects, like sending email.
|
||||
|
||||
Data available on this event:
|
||||
|
||||
- `phid` The PHID of the updated object.
|
||||
- `object` The object which was updated (like a @{class:ManiphesTask}).
|
||||
- `document` The @{class:PhabricatorSearchAbstractDocument} which was indexed.
|
||||
This contains an abstract representation of the object, and may be useful
|
||||
in populating secondary indexes because it provides a uniform API.
|
||||
|
||||
== Test: Did Run Test ==
|
||||
|
||||
The constant for this event is
|
||||
|
|
|
@ -27,6 +27,4 @@ final class PhabricatorEventType extends PhutilEventType {
|
|||
const TYPE_AUTH_WILLLOGINUSER = 'auth.willLoginUser';
|
||||
const TYPE_AUTH_DIDVERIFYEMAIL = 'auth.didVerifyEmail';
|
||||
|
||||
const TYPE_SEARCH_DIDUPDATEINDEX = 'search.didUpdateIndex';
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue