From: Jaap Jansma Date: Mon, 12 Apr 2021 07:37:57 +0000 (+0200) Subject: Fixed typo and added check for whether is empty X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=afbc86975ad8f250d9a62144f260ee98269a35fe;p=civicrm-core.git Fixed typo and added check for whether is empty --- diff --git a/CRM/Contact/BAO/Query.php b/CRM/Contact/BAO/Query.php index 76686c7848..1e268336ba 100644 --- a/CRM/Contact/BAO/Query.php +++ b/CRM/Contact/BAO/Query.php @@ -5837,6 +5837,9 @@ AND displayRelType.is_active = 1 else { $from .= $qcache['from']; } + if (!strlen($where)) { + $where = " WHERE 1 "; + } $where .= $qcache['where']; if (!empty($this->_tables['civicrm_case'])) { // Change the join on CiviCRM case so that it joins on the right contac from the relationship. diff --git a/tests/phpunit/CRM/Case/BAO/QueryTest.php b/tests/phpunit/CRM/Case/BAO/QueryTest.php index 3c34c76eec..87fc0e344d 100644 --- a/tests/phpunit/CRM/Case/BAO/QueryTest.php +++ b/tests/phpunit/CRM/Case/BAO/QueryTest.php @@ -145,7 +145,7 @@ class CRM_Case_BAO_QueryTest extends CiviCaseTestCase { $clientContactID = $this->individualCreate(['first_name' => 'John', 'last_name' => 'Smith']); $benefitSpecialist1 = $this->individualCreate(['Individual', 'first_name' => 'Alexa', 'last_name' => 'Clarke']); $benefitSpecialist2 = $this->individualCreate(['Individual', 'first_name' => 'Sandra', 'last_name' => 'Johnson']); - $housingSupportCase = $this->createCase($clientContactID, NULL, ['case_type_id' => 'housing_support', 'case_type_id' => 1]); + $housingSupportCase = $this->createCase($clientContactID, NULL, ['case_type' => 'housing_support', 'case_type_id' => 1]); $adultDayCareReferralCase = $this->createCase($clientContactID, NULL, ['case_type' => 'adult_day_care_referral', 'case_type_id' => 2]); civicrm_api3('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist1, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $housingSupportCase->id]); civicrm_api3('Relationship', 'create', ['contact_id_a' => $clientContactID, 'contact_id_b' => $benefitSpecialist2, 'relationship_type_id' => $benefitRelationshipTypeId, 'case_id' => $adultDayCareReferralCase->id]);