Page MenuHomePhabricator

D20795.id49584.diff
No OneTemporary

D20795.id49584.diff

diff --git a/resources/sql/autopatches/20190909.herald.01.rebuild.php b/resources/sql/autopatches/20190909.herald.01.rebuild.php
new file mode 100644
--- /dev/null
+++ b/resources/sql/autopatches/20190909.herald.01.rebuild.php
@@ -0,0 +1,3 @@
+<?php
+
+PhabricatorRebuildIndexesWorker::rebuildObjectsWithQuery('HeraldRuleQuery');
diff --git a/src/applications/herald/engineextension/HeraldRuleIndexEngineExtension.php b/src/applications/herald/engineextension/HeraldRuleIndexEngineExtension.php
--- a/src/applications/herald/engineextension/HeraldRuleIndexEngineExtension.php
+++ b/src/applications/herald/engineextension/HeraldRuleIndexEngineExtension.php
@@ -37,6 +37,20 @@
$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();
foreach ($rule->getActions() as $action_record) {
$action = idx($actions, $action_record->getAction());
diff --git a/src/applications/herald/field/HeraldField.php b/src/applications/herald/field/HeraldField.php
--- a/src/applications/herald/field/HeraldField.php
+++ b/src/applications/herald/field/HeraldField.php
@@ -176,6 +176,28 @@
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) {
$this->adapter = $adapter;
return $this;

File Metadata

Mime Type
text/plain
Expires
Sun, Mar 9, 4:10 AM (2 w, 3 h ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7225878
Default Alt Text
D20795.id49584.diff (2 KB)

Event Timeline