mirror of
https://we.phorge.it/source/phorge.git
synced 2025-01-19 19:21:10 +01:00
Support "only the first time" in Maniphest
Summary: Ref T4403. Implements "only the first time" for Maniphest rules, and fixes the trigger itself. The trigger would never fire and block rules because it was comparing a string (like "first") to an int (like 0). The "only" vs "every" stuff is contributed and I should have pushed back harder on this toInt / toString stuff. Maybe I'll just get rid of it; it purely causes confusion and problems. Test Plan: Wrote an "only the first time" rule, ran it twice, it applied once. Reviewers: btrahan Reviewed By: btrahan CC: aran Maniphest Tasks: T4403 Differential Revision: https://secure.phabricator.com/D8193
This commit is contained in:
parent
a3acf5fc4b
commit
094922bcb9
3 changed files with 14 additions and 3 deletions
|
@ -19,6 +19,13 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
|
||||||
'React to tasks being created or updated.');
|
'React to tasks being created or updated.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getRepetitionOptions() {
|
||||||
|
return array(
|
||||||
|
HeraldRepetitionPolicyConfig::EVERY,
|
||||||
|
HeraldRepetitionPolicyConfig::FIRST,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function supportsRuleType($rule_type) {
|
public function supportsRuleType($rule_type) {
|
||||||
switch ($rule_type) {
|
switch ($rule_type) {
|
||||||
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:
|
||||||
|
|
|
@ -61,10 +61,14 @@ final class HeraldEngine {
|
||||||
$effects = array();
|
$effects = array();
|
||||||
foreach ($rules as $phid => $rule) {
|
foreach ($rules as $phid => $rule) {
|
||||||
$this->stack = array();
|
$this->stack = array();
|
||||||
|
|
||||||
|
$policy_first = HeraldRepetitionPolicyConfig::FIRST;
|
||||||
|
$policy_first_int = HeraldRepetitionPolicyConfig::toInt($policy_first);
|
||||||
|
$is_first_only = ($rule->getRepetitionPolicy() == $policy_first_int);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (!$this->getDryRun() &&
|
if (!$this->getDryRun() &&
|
||||||
($rule->getRepetitionPolicy() ==
|
$is_first_only &&
|
||||||
HeraldRepetitionPolicyConfig::FIRST) &&
|
|
||||||
$rule->getRuleApplied($object->getPHID())) {
|
$rule->getRuleApplied($object->getPHID())) {
|
||||||
// This is not a dry run, and this rule is only supposed to be
|
// This is not a dry run, and this rule is only supposed to be
|
||||||
// applied a single time, and it's already been applied...
|
// applied a single time, and it's already been applied...
|
||||||
|
|
|
@ -17,7 +17,7 @@ final class HeraldRule extends HeraldDAO
|
||||||
protected $isDisabled = 0;
|
protected $isDisabled = 0;
|
||||||
protected $triggerObjectPHID;
|
protected $triggerObjectPHID;
|
||||||
|
|
||||||
protected $configVersion = 30;
|
protected $configVersion = 31;
|
||||||
|
|
||||||
// phids for which this rule has been applied
|
// phids for which this rule has been applied
|
||||||
private $ruleApplied = self::ATTACHABLE;
|
private $ruleApplied = self::ATTACHABLE;
|
||||||
|
|
Loading…
Reference in a new issue