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

multiple values returned if multiple location types represented

    Details

    • Type: Bug
    • Status: Done/Fixed
    • Priority: Major
    • Resolution: Won't Fix
    • Affects Version/s: 3.3.0
    • Fix Version/s: 4.3.0
    • Component/s: CiviCRM Profile
    • Labels:
      None

      Description

      http://drupal.demo.civicrm.org/civicrm/profile/search?gid=10&reset=1
      (search with no criteria)

      in profile search:
      IF address, phone, email present
      AND all set to primary
      AND some records in the results exist where primary location types are different
      THEN duplicate records returned

      for example, if John Doe has primary address = home and primary email = work

      problem is with how Contact/BAO/Query.php handles the location type. it concatenates all references in a single left join ON clause separated by OR:

      LEFT JOIN civicrm_location_type `1-location_type` ON ( ( `1-address`.location_type_id = `1-location_type`.id ) OR ( `1-phone-1`.location_type_id = `1-location_type`.id ) OR ( `1-email`.location_type_id = `1-location_type`.id ) )

      per IRC with Lobo, recommends:

      a. eliminate the inclusion of location type table completely
      b. retrieve the location types array and resolve the ids from the address/phone/email when rendering if location is needed
      c. if location types are used, basically do b and include them in the ON clause when we are doing a LEFT JOIN on the address/phone/email i.e. avoid joining lcoation type table (which i think will be a nice optimization also

      see: http://paste2.org/p/1131459
      for full query

        Attachments

          Activity

            People

            • Assignee:
              lobo Donald A. Lobo
              Reporter:
              lcdweb Brian Shaughnessy
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: