Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Minor
-
Resolution: Fixed/Completed
-
Affects Version/s: 4.6.8
-
Fix Version/s: 4.7
-
Component/s: CiviCRM Search
-
Labels:
-
Documentation Required?:None
-
Funding Source:Core Team Funds
Description
When using advanced search, searching for contacts with a custom relationship type, the search doesn't find any contacts and a undefined index notice is displayed.
To reproduce:
Login on http://d46.demo.civicrm.org/ create a custom relationship (I haven't testet all kinds of relationship, but I created one for Student <-> Team), go to advanced search, select Students as contact type to search for, select your newly created relationship type under relationships, and click search. This gives you these notices:
Notice: Undefined index: 15_a_b in CRM_Contact_BAO_Query->relationship() (line 4013 of /srv/buildkit/build/d46/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php).
Notice: Undefined index: 15_a_b in CRM_Contact_BAO_Query->relationship() (line 4013 of /srv/buildkit/build/d46/sites/all/modules/civicrm/CRM/Contact/BAO/Query.php).
NB: the demo is 4.6.9 - in 4.6.8 the error occurs at line 4084.
This happens because the custom relationship type isn't in the array $allRelationshipType, which gets build by this code in Query.php (around line 3970):
$relTypeInd = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Individual');
$relTypeOrg = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Organization');
$relTypeHou = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, 'Household');
$allRelationshipType = array();
$allRelationshipType = array_merge($relTypeInd, $relTypeOrg);
$allRelationshipType = array_merge($allRelationshipType, $relTypeHou);
I'm not sure but, couldn't this just be:
$allRelationshipType = CRM_Contact_BAO_Relationship::getContactRelationshipType(NULL, 'null', NULL, NULL, TRUE);
then we would get all relationship types.