Fix https://github.com/firefly-iii/firefly-iii/issues/8291 AND fix issue with non-strict rule triggers AND fix behaviour of actions

This commit is contained in:
James Cole
2023-12-25 06:03:56 +01:00
parent 2b90c20db8
commit 1bd1a9cba3
5 changed files with 36 additions and 12 deletions

View File

@@ -325,6 +325,12 @@ class SearchRuleEngine implements RuleEngineInterface
$total = $total->merge($collection);
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
++$count;
// if trigger says stop processing, do so.
if($ruleTrigger->stop_processing && $collection->count() > 0) {
app('log')->debug('The trigger says to stop processing, so stop processing other triggers.');
break;
}
}
app('log')->debug(sprintf('Total collection is now %d transactions', $total->count()));
app('log')->debug(sprintf('Done running %d trigger(s)', $count));
@@ -465,11 +471,14 @@ class SearchRuleEngine implements RuleEngineInterface
}
// pick up from the action if it actually acted or not:
if ($ruleAction->stop_processing) {
app('log')->debug(sprintf('Rule action "%s" asks to break, so break!', $ruleAction->action_type));
if ($ruleAction->stop_processing && true === $result) {
app('log')->debug(sprintf('Rule action "%s" reports changes AND asks to break, so break!', $ruleAction->action_type));
return true;
}
if ($ruleAction->stop_processing && false === $result) {
app('log')->debug(sprintf('Rule action "%s" reports NO changes AND asks to break, but we wont break!', $ruleAction->action_type));
}
return false;
}