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 15, 2017
1 parent 03cefdd commit 9d180e3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 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
13 changes: 9 additions & 4 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 @@ -326,11 +326,11 @@ protected function buildAddlRepeatPass() {
->merge($this->selectActionLogFields(self::PHASE_ADDITION_REPEAT, $query))
->merge($this->joinReminder('INNER JOIN', 'addl', $query))
->select("MAX(reminder.action_date_time) as latest_log_time")
->merge($this->prepareAddlFilter('c.id'))
->merge($this->prepareAddlFilter('c.id'), array('params'))
->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 @@ -572,7 +572,12 @@ protected function selectActionLogFields($phase, $query) {

case self::PHASE_ADDITION_FIRST:
case self::PHASE_ADDITION_REPEAT:
$fragment = \CRM_Utils_SQL_Select::fragment();
//CRM-19017: Load default params for fragment query object.
$params = array(
'casActionScheduleId' => $this->actionSchedule->id,
'casNow' => $this->now,
);
$fragment = \CRM_Utils_SQL_Select::fragment()->param($params);
$fragment->select(
array(
"c.id as contact_id",
Expand Down

0 comments on commit 9d180e3

Please sign in to comment.