Page MenuHomePhabricator

D12957.id31228.diff
No OneTemporary

D12957.id31228.diff

diff --git a/src/applications/herald/adapter/HeraldAdapter.php b/src/applications/herald/adapter/HeraldAdapter.php
--- a/src/applications/herald/adapter/HeraldAdapter.php
+++ b/src/applications/herald/adapter/HeraldAdapter.php
@@ -536,7 +536,9 @@
return $this->getCustomFieldConditions($field);
}
throw new Exception(
- "This adapter does not define conditions for field '{$field}'!");
+ pht(
+ "This adapter does not define conditions for field '%s'!",
+ $field));
}
}
@@ -1041,7 +1043,10 @@
return $custom_action->getActionType();
}
- throw new Exception("Unknown or invalid action '".$action."'.");
+ throw new Exception(
+ pht(
+ "Unknown or invalid action '%s'.",
+ $action));
}
@@ -1197,7 +1202,15 @@
$rule_global = HeraldRuleTypeConfig::RULE_TYPE_GLOBAL;
$action_type = $action->getAction();
- $action_name = idx($this->getActionNameMap($rule_global), $action_type);
+
+ $default = $this->isHeraldCustomKey($action_type)
+ ? pht('(Unknown Custom Action "%s") equals', $action_type)
+ : pht('(Unknown Action "%s") equals', $action_type);
+
+ $action_name = idx(
+ $this->getActionNameMap($rule_global),
+ $action_type,
+ $default);
$target = $this->renderActionTargetAsText($action, $handles);
@@ -1519,7 +1532,9 @@
$supported = $this->getActions($rule_type);
$supported = array_fuse($supported);
if (empty($supported[$action])) {
- throw new Exception(
+ return new HeraldApplyTranscript(
+ $effect,
+ false,
pht(
'Adapter "%s" does not support action "%s" for rule type "%s".',
get_class($this),
@@ -1542,7 +1557,9 @@
$result = $this->handleCustomHeraldEffect($effect);
if (!$result) {
- throw new Exception(
+ return new HeraldApplyTranscript(
+ $effect,
+ false,
pht(
'No custom action exists to handle rule action "%s".',
$action));
diff --git a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php b/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
--- a/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
+++ b/src/applications/herald/adapter/HeraldDifferentialDiffAdapter.php
@@ -154,7 +154,10 @@
pht('Blocked diff.'));
break;
default:
- throw new Exception(pht('No rules to handle action "%s"!', $action));
+ $result[] = new HeraldApplyTranscript(
+ $effect,
+ false,
+ pht('No rules to handle action "%s"!', $action));
}
}
diff --git a/src/applications/herald/controller/HeraldRuleController.php b/src/applications/herald/controller/HeraldRuleController.php
--- a/src/applications/herald/controller/HeraldRuleController.php
+++ b/src/applications/herald/controller/HeraldRuleController.php
@@ -354,7 +354,6 @@
if ($rule->getConditions()) {
$serial_conditions = array();
foreach ($rule->getConditions() as $condition) {
-
$value = $condition->getValue();
switch ($condition->getFieldName()) {
case HeraldAdapter::FIELD_TASK_PRIORITY:
@@ -394,10 +393,10 @@
$serial_actions = array(
array('default', ''),
);
+
if ($rule->getActions()) {
$serial_actions = array();
foreach ($rule->getActions() as $action) {
-
switch ($action->getAction()) {
case HeraldAdapter::ACTION_FLAG:
case HeraldAdapter::ACTION_BLOCK:
@@ -446,13 +445,27 @@
$actions = $adapter->getActions($rule->getRuleType());
$action_map = array_select_keys($all_actions, $actions);
+ // Populate any actions which exist in the rule but which we don't know the
+ // names of, so that saving a rule without touching anything doesn't change
+ // it.
+ foreach ($rule->getActions() as $action) {
+ if (empty($action_map[$action->getAction()])) {
+ $action_map[$action->getAction()] = pht('<Unknown Action>');
+ }
+ }
+
+
$config_info = array();
$config_info['fields'] = $field_map;
$config_info['conditions'] = $all_conditions;
$config_info['actions'] = $action_map;
foreach ($config_info['fields'] as $field => $name) {
- $field_conditions = $adapter->getConditionsForField($field);
+ try {
+ $field_conditions = $adapter->getConditionsForField($field);
+ } catch (Exception $ex) {
+ $field_conditions = array(HeraldAdapter::CONDITION_UNCONDITIONALLY);
+ }
$config_info['conditionMap'][$field] = $field_conditions;
}
@@ -468,9 +481,15 @@
$config_info['rule_type'] = $rule->getRuleType();
foreach ($config_info['actions'] as $action => $name) {
- $config_info['targets'][$action] = $adapter->getValueTypeForAction(
- $action,
- $rule->getRuleType());
+ try {
+ $action_value = $adapter->getValueTypeForAction(
+ $action,
+ $rule->getRuleType());
+ } catch (Exception $ex) {
+ $action_value = array(HeraldAdapter::VALUE_NONE);
+ }
+
+ $config_info['targets'][$action] = $action_value;
}
$changeflag_options =
diff --git a/src/applications/herald/engine/HeraldEngine.php b/src/applications/herald/engine/HeraldEngine.php
--- a/src/applications/herald/engine/HeraldEngine.php
+++ b/src/applications/herald/engine/HeraldEngine.php
@@ -269,6 +269,17 @@
$result = false;
} else {
foreach ($conditions as $condition) {
+
+ try {
+ $object->getHeraldField($condition->getFieldName());
+ } catch (Exception $ex) {
+ $reason = pht(
+ 'Field "%s" does not exist!',
+ $condition->getFieldName());
+ $result = false;
+ break;
+ }
+
$match = $this->doesConditionMatch($rule, $condition, $object);
if (!$all && $match) {
diff --git a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
--- a/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
+++ b/webroot/rsrc/js/application/herald/HeraldRuleEditor.js
@@ -254,6 +254,11 @@
_renderValueInputForRow : function(row_id) {
var cond = this._config.conditions[row_id];
+
+ if (!cond[1]) {
+ return;
+ }
+
var type = this._config.info.values[cond[0]][cond[1]];
var input = this._buildInput(type);

File Metadata

Mime Type
text/plain
Expires
Thu, Mar 20, 10:17 PM (1 d, 21 m ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7707269
Default Alt Text
D12957.id31228.diff (6 KB)

Event Timeline