1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-09-20 01:08:50 +02: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:
epriestley 2014-02-11 07:45:26 -08:00
parent a3acf5fc4b
commit 094922bcb9
3 changed files with 14 additions and 3 deletions

View file

@ -19,6 +19,13 @@ final class HeraldManiphestTaskAdapter extends HeraldAdapter {
'React to tasks being created or updated.');
}
public function getRepetitionOptions() {
return array(
HeraldRepetitionPolicyConfig::EVERY,
HeraldRepetitionPolicyConfig::FIRST,
);
}
public function supportsRuleType($rule_type) {
switch ($rule_type) {
case HeraldRuleTypeConfig::RULE_TYPE_GLOBAL:

View file

@ -61,10 +61,14 @@ final class HeraldEngine {
$effects = array();
foreach ($rules as $phid => $rule) {
$this->stack = array();
$policy_first = HeraldRepetitionPolicyConfig::FIRST;
$policy_first_int = HeraldRepetitionPolicyConfig::toInt($policy_first);
$is_first_only = ($rule->getRepetitionPolicy() == $policy_first_int);
try {
if (!$this->getDryRun() &&
($rule->getRepetitionPolicy() ==
HeraldRepetitionPolicyConfig::FIRST) &&
$is_first_only &&
$rule->getRuleApplied($object->getPHID())) {
// This is not a dry run, and this rule is only supposed to be
// applied a single time, and it's already been applied...

View file

@ -17,7 +17,7 @@ final class HeraldRule extends HeraldDAO
protected $isDisabled = 0;
protected $triggerObjectPHID;
protected $configVersion = 30;
protected $configVersion = 31;
// phids for which this rule has been applied
private $ruleApplied = self::ATTACHABLE;