diff --git a/api/v3/Contact.php b/api/v3/Contact.php index 3c2fc5bed28f..bcaa9954cc8b 100644 --- a/api/v3/Contact.php +++ b/api/v3/Contact.php @@ -163,6 +163,8 @@ function _civicrm_api3_contact_create_spec(&$params) { * * @return array * API Result Array + * + * @throws \API_Exception */ function civicrm_api3_contact_get($params) { $options = []; @@ -382,6 +384,11 @@ function _civicrm_api3_contact_get_spec(&$params) { * Array of options (so we can modify the filter). */ function _civicrm_api3_contact_get_supportanomalies(&$params, &$options) { + if (!empty($params['email']) && !is_array($params['email'])) { + // Fix this to be in array format so the query object does not add LIKE + // I think there is a better fix that I will do for master. + $params['email'] = ['=' => $params['email']]; + } if (isset($params['showAll'])) { if (strtolower($params['showAll']) == "active") { $params['contact_is_deleted'] = 0; diff --git a/tests/phpunit/api/v3/ContactTest.php b/tests/phpunit/api/v3/ContactTest.php index 3883c0ecee02..03dd75effaf0 100644 --- a/tests/phpunit/api/v3/ContactTest.php +++ b/tests/phpunit/api/v3/ContactTest.php @@ -367,6 +367,8 @@ public function testCreateBadRequiredFieldsOrganization() { /** * Verify that attempt to create individual contact with only an email succeeds. + * + * @throws \CRM_Core_Exception */ public function testCreateEmailIndividual() { $primaryEmail = 'man3@yahoo.com'; @@ -397,10 +399,12 @@ public function testCreateEmailIndividual() { $this->assertEquals($primaryEmail, $email1['values'][$email1['id']]['email']); // Case 3: Check with email_id='primary email id' - $result = $this->callAPISuccess('contact', 'get', ['email_id' => $email1['id']]); - $this->assertEquals(1, $result['count']); + $result = $this->callAPISuccessGetSingle('contact', ['email_id' => $email1['id']]); $this->assertEquals($contact1['id'], $result['id']); + // Check no wildcard is appended + $this->callAPISuccessGetCount('Contact', ['email' => 'man3@yahoo.co'], 0); + $this->callAPISuccess('contact', 'delete', $contact1); }