Skip to content

Fix warning on Manage CiviRules screen when a CR was never triggered

If there are CiviRules that never have been triggered, a warning is visible on the Manage CiviRules screen:

Warning: reset() expects parameter 1 to be array, null given in CRM_Civirules_Form_RuleView->getRules() (line 82 of xxxxxxx/CRM/Civirules/Form/RuleView.php).

That line tries to reset $triggerDetail array, which is returned from CRM_Civirules_Utils::getRuleLogLatestTriggerDetail($dao->rule_id, 1). If there are no rows in the civirule_rule_log table for a given CiviRule it will return null, hence the warning.

In this PR I've added an initial value so it will return an empty array.

Merge request reports

Loading