From 599f847ddaf5fefced91aefcad33f00f85e73432 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Fri, 26 Sep 2014 15:35:57 +1200 Subject: [PATCH] CRM-15376 fix for membership reminders going out after renewal --- CRM/Core/BAO/ActionSchedule.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CRM/Core/BAO/ActionSchedule.php b/CRM/Core/BAO/ActionSchedule.php index 62c5704fd0..b6ed98b42f 100755 --- a/CRM/Core/BAO/ActionSchedule.php +++ b/CRM/Core/BAO/ActionSchedule.php @@ -1078,11 +1078,17 @@ GROUP BY c.id $havingClause = "HAVING TIMEDIFF({$now}, latest_log_time) >= TIME('{$hrs}:00:00')"; $groupByClause = 'GROUP BY reminder.contact_id, reminder.entity_id, reminder.entity_table'; $selectClause .= ', MAX(reminder.action_date_time) as latest_log_time'; + //CRM-15376 - do not send our reminders if original criteria no longer applies + // the first part of the startDateClause array is the earliest the reminder can be sent. If the + // event (e.g membership_end_date) has changed then the reminder may no longer apply + // @todo - this only handles events that get moved later. Potentially they might get moved earlier + $originalEventStartDateClause = empty($startDateClause) ? '' : 'AND' . $startDateClause[0]; + $sqlInsertValues = "{$selectClause} {$fromClause} {$joinClause} INNER JOIN {$reminderJoinClause} -{$whereClause} {$limitWhereClause} AND {$repeatEventClause} +{$whereClause} {$limitWhereClause} AND {$repeatEventClause} $originalEventStartDateClause {$groupByClause} {$havingClause}"; -- 2.25.1