mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Index Herald fields, not just actions, when identifying objects related to a particular Herald rule
Summary: Fixes T13408. Currently, when a package (or other object) appears in a field (rather than an action), it is not indexed. Instead: index fields too, not just actions. Test Plan: - Wrote a rule like "[ Affected packages include ] ...". - Updated the search index. - Saw rule appear on "Affected By Herald Rules" on the package detail page. Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13408 Differential Revision: https://secure.phabricator.com/D20795
This commit is contained in:
parent
aaaea57591
commit
d965d9a669
3 changed files with 39 additions and 0 deletions
3
resources/sql/autopatches/20190909.herald.01.rebuild.php
Normal file
3
resources/sql/autopatches/20190909.herald.01.rebuild.php
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery('HeraldRuleQuery');
|
|
@ -37,6 +37,20 @@ final class HeraldRuleIndexEngineExtension
|
||||||
|
|
||||||
$phids = array();
|
$phids = array();
|
||||||
|
|
||||||
|
$fields = HeraldField::getAllFields();
|
||||||
|
foreach ($rule->getConditions() as $condition_record) {
|
||||||
|
$field = idx($fields, $condition_record->getFieldName());
|
||||||
|
|
||||||
|
if (!$field) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$affected_phids = $field->getPHIDsAffectedByCondition($condition_record);
|
||||||
|
foreach ($affected_phids as $phid) {
|
||||||
|
$phids[] = $phid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$actions = HeraldAction::getAllActions();
|
$actions = HeraldAction::getAllActions();
|
||||||
foreach ($rule->getActions() as $action_record) {
|
foreach ($rule->getActions() as $action_record) {
|
||||||
$action = idx($actions, $action_record->getAction());
|
$action = idx($actions, $action_record->getAction());
|
||||||
|
|
|
@ -176,6 +176,28 @@ abstract class HeraldField extends Phobject {
|
||||||
return $value_type->renderEditorValue($value);
|
return $value_type->renderEditorValue($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getPHIDsAffectedByCondition(HeraldCondition $condition) {
|
||||||
|
$phids = array();
|
||||||
|
|
||||||
|
$standard_type = $this->getHeraldFieldStandardType();
|
||||||
|
switch ($standard_type) {
|
||||||
|
case self::STANDARD_PHID:
|
||||||
|
case self::STANDARD_PHID_NULLABLE:
|
||||||
|
$phid = $condition->getValue();
|
||||||
|
if ($phid) {
|
||||||
|
$phids[] = $phid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case self::STANDARD_PHID_LIST:
|
||||||
|
foreach ($condition->getValue() as $phid) {
|
||||||
|
$phids[] = $phid;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $phids;
|
||||||
|
}
|
||||||
|
|
||||||
final public function setAdapter(HeraldAdapter $adapter) {
|
final public function setAdapter(HeraldAdapter $adapter) {
|
||||||
$this->adapter = $adapter;
|
$this->adapter = $adapter;
|
||||||
return $this;
|
return $this;
|
||||||
|
|
Loading…
Reference in a new issue