Details
-
Type: Bug
-
Status: Done/Fixed
-
Priority: Major
-
Resolution: Fixed/Completed
-
Affects Version/s: 1.6
-
Fix Version/s: 1.6
-
Component/s: None
-
Labels:None
Description
When using crm_get_relationships() with a requested relationship type restriction in the $relationship_types parameter, if no relationships of the types requested exist for the provided contact all relationships are returned. The expected behaviour is an empty array.
This can be resolved by adding " $relationships = $result;" to line 149 of the api/Relationship.php file. This likely breaks return results when providing both relationship types and a second contact, but thats not something I have tested.
I get the feeling that this function should be totally rewritten since these sorts of operations are best done in the db instead of returning all relationships for the object and paring down the needed ones with nested for/each loops. Perhaps a new method in the CRM_Contact_BAO_Relationship could handle this better?