diff --git a/CRM/Report/Form/Activity.php b/CRM/Report/Form/Activity.php index ed95a7722c04..cdaf918dfa06 100644 --- a/CRM/Report/Form/Activity.php +++ b/CRM/Report/Form/Activity.php @@ -542,7 +542,7 @@ public function where($recordType = NULL) { } else { $op = $this->_params["{$fieldName}_op"] ?? NULL; - if ($op && !($fieldName == "contact_{$recordType}" && ($op != 'nnll' || $op != 'nll'))) { + if ($op && !($fieldName === "contact_{$recordType}" && ($op === 'nnll' || $op === 'nll'))) { $clause = $this->whereClause($field, $op, CRM_Utils_Array::value("{$fieldName}_value", $this->_params), diff --git a/tests/phpunit/api/v3/ReportTemplateTest.php b/tests/phpunit/api/v3/ReportTemplateTest.php index 6316cde92e82..94bb75e412d8 100644 --- a/tests/phpunit/api/v3/ReportTemplateTest.php +++ b/tests/phpunit/api/v3/ReportTemplateTest.php @@ -1259,6 +1259,23 @@ public function testActivityDetailsNullFilters() { $this->assertEmpty($rowsWithNullTarget); } + /** + * Test the source contact filter works. + * + * @throws \CRM_Core_Exception + */ + public function testActivityDetailsContactFilter() { + $this->createContactsWithActivities(); + $params = [ + 'report_id' => 'activity', + 'contact_source_op' => 'has', + 'contact_source_value' => 'z', + 'options' => ['metadata' => ['sql']], + ]; + $rows = $this->callAPISuccess('report_template', 'getrows', $params); + $this->assertContains("civicrm_contact_source.sort_name LIKE '%z%'", $rows['metadata']['sql'][3]); + } + /** * Set up some activity data..... use some chars that challenge our utf handling. */