Skip to content

Commit

Permalink
Merge pull request #16553 from eileenmcnaughton/5222
Browse files Browse the repository at this point in the history
Backport patches for regressions merged to 5.23
  • Loading branch information
seamuslee001 authored Feb 15, 2020
2 parents 2938ae5 + 4d780d9 commit 547c4b9
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
50 changes: 36 additions & 14 deletions CRM/Contact/BAO/Query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,10 @@ public function whereClauseSingle(&$values, $isForcePrimaryOnly = FALSE) {
(substr($values[0], 0, 10) === 'financial_') ||
(substr($values[0], 0, 8) === 'payment_') ||
(substr($values[0], 0, 11) === 'membership_')
// temporary fix for regression https://lab.civicrm.org/dev/core/issues/1551
// ideally the metadata would allow this field to be parsed below & the special handling would not
// be needed.
|| $values[0] === 'mailing_id'
) {
return;
}
Expand Down Expand Up @@ -4215,7 +4219,7 @@ public function relationship(&$values) {
}
$this->_qill[$grouping][] = 'Relationship Type(s) ' . $relQill . " $name";
}
else {
elseif ($name) {
$this->_qill[$grouping][] = $name;
}
}
Expand Down Expand Up @@ -7074,22 +7078,22 @@ protected function buildRelativeDateQuery(&$values) {
$secondWhere = str_replace('civicrm_contact.', 'contact_a.', $secondWhere);
}

$this->_qill[$grouping][] = $this->getQillForRelativeDateRange($dates[0], $dates[1], $fieldSpec['title'], $filters[$value]);
if ($fieldName === 'relation_active_period_date') {
// Hack this to fix regression https://lab.civicrm.org/dev/core/issues/1592
// Not sure the 'right' fix.
$this->_where[$grouping] = [self::getRelationshipActivePeriodClauses($dates[0], $dates[1], TRUE)];
return;
}

if (empty($dates[0])) {
// ie. no start date we only have end date
$this->_where[$grouping][] = $secondWhere . " <= '{$dates[1]}'";

$this->_qill[$grouping][] = ts('%1 is ', [$fieldSpec['title']]) . $filters[$value] . ' (' . ts("to %1", [
CRM_Utils_Date::customFormat($dates[1]),
]) . ')';
}
elseif (empty($dates[1])) {

// ie. no end date we only have start date
$this->_where[$grouping][] = $where . " >= '{$dates[0]}'";

$this->_qill[$grouping][] = ts('%1 is ', [$fieldSpec['title']]) . $filters[$value] . ' (' . ts("from %1", [
CRM_Utils_Date::customFormat($dates[0]),
]) . ')';
}
else {
// we have start and end dates.
Expand All @@ -7099,11 +7103,6 @@ protected function buildRelativeDateQuery(&$values) {
else {
$this->_where[$grouping][] = $where . " BETWEEN '{$dates[0]}' AND '{$dates[1]}'";
}

$this->_qill[$grouping][] = ts('%1 is ', [$fieldSpec['title']]) . $filters[$value] . ' (' . ts("between %1 and %2", [
CRM_Utils_Date::customFormat($dates[0]),
CRM_Utils_Date::customFormat($dates[1]),
]) . ')';
}
}

Expand Down Expand Up @@ -7231,4 +7230,27 @@ public function handleWhereFromMetadata($fieldSpec, $name, $value, $op, $groupin
}
}

/**
* Get the qill for the relative date range.
*
* @param string|null $from
* @param string|null $to
* @param string $fieldTitle
* @param string $relativeRange
*
* @return string
*/
protected function getQillForRelativeDateRange($from, $to, string $fieldTitle, string $relativeRange): string {
if (!$from) {
return ts('%1 is ', [$fieldTitle]) . $relativeRange . ' (' . ts('to %1', [CRM_Utils_Date::customFormat($to)]) . ')';
}
if (!$to) {
return ts('%1 is ', [$fieldTitle]) . $relativeRange . ' (' . ts('from %1', [CRM_Utils_Date::customFormat($from)]) . ')';
}
return ts('%1 is ', [$fieldTitle]) . $relativeRange . ' (' . ts('between %1 and %2', [
CRM_Utils_Date::customFormat($from),
CRM_Utils_Date::customFormat($to),
]) . ')';
}

}
1 change: 1 addition & 0 deletions CRM/Contribute/Form/Contribution/Confirm.php
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,7 @@ public static function getFormParams($id, array $params) {
* @param int $contactID
*
* @return array
* @throws \CRM_Core_Exception
*/
protected function processFormSubmission($contactID) {
if (!isset($this->_params['payment_processor_id'])) {
Expand Down
4 changes: 2 additions & 2 deletions Civi/Payment/PropertyBag.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,9 +252,9 @@ public function has($prop, $label = 'default') {
* @param array $data
*/
public function mergeLegacyInputParams($data) {
$this->legacyWarning("We have merged input params into the property bag for now but please rewrite code to not use this.");
$this->legacyWarning('We have merged input params into the property bag for now but please rewrite code to not use this.');
foreach ($data as $key => $value) {
if ($value !== NULL) {
if ($value !== NULL && $value !== '') {
$this->offsetSet($key, $value);
}
}
Expand Down

0 comments on commit 547c4b9

Please sign in to comment.