Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-17269

advanced search with custom relationship types fails

    Details

    • 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.

        Attachments

          Activity

            People

            • Assignee:
              dgg David Greenberg
              Reporter:
              andersiversen Anders Iversen
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - 1 hour
                1h
                Remaining:
                Remaining Estimate - 1 hour
                1h
                Logged:
                Time Spent - Not Specified
                Not Specified