Skip to content

Commit

Permalink
CRM-19017 : Load default params for fragment query object.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jitendra Purohit committed Jul 13, 2017
1 parent 03cefdd commit 1318e49
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CRM/Member/ActionMapping.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function createQuery($schedule, $phase, $defaultParams) {
$selectedValues = (array) \CRM_Utils_Array::explodePadded($schedule->entity_value);
$selectedStatuses = (array) \CRM_Utils_Array::explodePadded($schedule->entity_status);

$query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);;
$query = \CRM_Utils_SQL_Select::from("{$this->entity} e")->param($defaultParams);
$query['casAddlCheckFrom'] = 'civicrm_membership e';
$query['casContactIdField'] = 'e.contact_id';
$query['casEntityIdField'] = 'e.id';
Expand Down
16 changes: 13 additions & 3 deletions Civi/ActionSchedule/RecipientBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ protected function buildAddlRepeatPass() {

$addlCheck = \CRM_Utils_SQL_Select::from($query['casAddlCheckFrom'])
->select('*')
->merge($query, array('wheres'))// why only where? why not the joins?
->merge($query, array('params', 'wheres'))// why only where? why not the joins?
->merge($this->prepareRepetitionEndFilter($query['casDateField']))
->limit(1)
->strict()
Expand All @@ -323,14 +323,14 @@ protected function buildAddlRepeatPass() {
$daoCheck = \CRM_Core_DAO::executeQuery($addlCheck);
if ($daoCheck->fetch()) {
$repeatInsertAddl = \CRM_Utils_SQL_Select::from('civicrm_contact c')
->merge($this->selectActionLogFields(self::PHASE_ADDITION_REPEAT, $query))
->merge($this->selectActionLogFields(self::PHASE_ADDITION_REPEAT, $query), array('params'))
->merge($this->joinReminder('INNER JOIN', 'addl', $query))
->select("MAX(reminder.action_date_time) as latest_log_time")
->merge($this->prepareAddlFilter('c.id'))
->where("c.is_deleted = 0 AND c.is_deceased = 0")
->groupBy("reminder.contact_id")
// @todo replace use of timestampdiff with a direct comparison as TIMESTAMPDIFF cannot use an index.
->having("TIMESTAMPDIFF(HOUR, latest_log_time, CAST(!casNow AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL !casRepetitionInterval)")
->having("TIMESTAMPDIFF(HOUR, latest_log_time, CAST(!casNow AS datetime)) >= TIMESTAMPDIFF(HOUR, latest_log_time, DATE_ADD(latest_log_time, INTERVAL !casRepetitionInterval))")
->param(array(
'casRepetitionInterval' => $this->parseRepetitionInterval(),
))
Expand Down Expand Up @@ -581,6 +581,16 @@ protected function selectActionLogFields($phase, $query) {
"#casActionScheduleId as action_schedule_id",
)
);
//CRM-19017: Load default params for fragment query object.
$params = array(
'casActionScheduleId' => $this->actionSchedule->id,
'casNow' => $this->now,
);
foreach ($params as $key => $val) {
if (empty($fragment->params[$key])) {
$fragment->param($key, $val);
}
}
break;

default:
Expand Down

0 comments on commit 1318e49

Please sign in to comment.