Change of Membership State causes Membership Renewed trigger to misbehave
When the 'Update Membership Statuses' scheduled job changes the membership state, e.g. from Current to Grace, the code in civirules/CRM/CivirulesPostTrigger/MembershipRenewed.php
(which is testing to see if a renewal has occurred) generates three error log messages before failing. For example:
Notice: Undefined index: membership_join_date in CRM_CivirulesPostTrigger_MembershipRenewed->triggerTrigger() (line 46 of .../civirules/CRM/CivirulesPostTrigger/MembershipRenewed.php).
In itself this does not cause a malfunction but until recently our membership policy was that all memberships expired on a fixed date, so there is a large spike at or near this date. The result is many pages of messages in the log, the job exceeds some resource limit and is terminated by the system without finishing. This causes the whole cron job to fail at this point.
The reason is that a change of membership state triggers the post processing activity, but does not supply all the necessary information in the call to $triggerData->getEntityData('Membership')
at line 38 of /civirules/CRM/CivirulesPostTrigger/MembershipRenewed.php
. I have added the following patch to our system at line 41 which prevents the change of state causing problems, but allows actual membership renewals to trigger correctly.
// Pure change of membership state, e.g. by scheduled job Update Membership Statuses
// does not supply all required information, but is not a Renewal, so escape.
if( !isset($membership['membership_type_id']) || !isset($membership['membership_join_date']) || !isset($membership['end_date']) ) {
return;
}
This has been raised as Merge Request !156 (merged).