CRM-17847 Fix custom field form notices w/ relationships between contact sub-types and default types

    Details

    • Versioning Impact:
      Patch (backwards-compatible bug fixes)
    • Documentation Required?:
      User and Admin Doc
    • Funding Source:
      Contributed Code

      Description

      When using a sub-type as the left-hand (A) side of a relationship with a default type on the right (B), the following notices appear on the custom fields form (/civicrm/admin/custom/group?action=add&reset=1):

      Notice: Undefined index: 20_a_b in CRM_Custom_Form_Group::getFormattedList() (line 536 of /.../civicrm/CRM/Custom/Form/Group.php).
      Notice: Undefined index: 20_a_b in CRM_Custom_Form_Group::getFormattedList() (line 538 of /.../civicrm/CRM/Custom/Form/Group.php).
      Notice: Undefined index: 20_a_b in CRM_Custom_Form_Group::getFormattedList() (line 539 of /.../civicrm/CRM/Custom/Form/Group.php).

      To reproduce:

      1. Create a contact subtype (e.g. 'student' as a sub-type of individual)
      2. Define a relationship between the new contact sub-type and a default contact type (e.g. organization)
      3. Add a 'New Custom Field Set' (/civicrm/admin/custom/group?action=add&reset=1) and the warning will be displayed.
      4. Select 'Relationships' in the 'Used for' field
      5. Scroll through the select box, and the relevant option will be missing part of the label.

      Note the following:

      • reversing the relationship resolves the issue (so there's an easy work-around)
      • having both contacts in the relationship be sub-types (another easy work-around).

      I haven't gone any further in testing whether this is really just a form-building/display bug, or whether defining a field based on this relationship would fail in other ways.

        Attachments

          Activity

          [CRM-17847] Fix custom field form notices w/ relationships between contact sub-types and default types
          Jemmyn Buchanan added a comment -

          Would love to fund to get this issue resolved if possible. What kind of time do you think is involved with a bug fix for this? Would that fix the issue in all platforms (ie. Drupal, Joomla, Wordpress)?
          Thanks!

          Coleman Watts added a comment -

          I think this would be a < 5 hour project for the core team. Please submit to https://civicrm.org/paid-issue-queue if interested in sponsoring.

          Mattias Michaux added a comment -

          I stumbled on this issue because I could't add any custom fields to relationships where one of the sides is a contact sub-type.
          Those relationships are not visible and I get a lot of warnings.

          I digged in to this and found 3 issues:

          • the code in CRM_Contact_BAO_Relationship::getContactRelationshipType just ignores the subtype, so it will never work for contact subtypes. see https://github.com/civicrm/civicrm-core/blob/master/CRM/Contact/BAO/Relationship.php#L554
          • the code in CRM_Custom_Form_Group::getFormattedList doesn't deal well with relationships that exists in both directions, as the keys may not exists anymore during processing of the array.
          • The CRM_Custom_Page_Group::browse method has its own logic for displaying the relationships, instead of using CRM_Custom_Form_Group::getFormattedList

          I created a PR for 4.6 and master to fix these issues.

          Mattias Michaux added a comment -

          Not completely sure, but I guess this will also fix CRM-17544 , as the fix in CRM_Contact_BAO_Relationship::getContactRelationshipType ensures the subtype isn't ignored.

          Eileen McNaughton added a comment -

          I just tried to reproduce this problem on dmaster but failed - so I'm guessing this got fixed some other way in the last  8 months - closing

            People

            • Assignee:
              Unassigned
              Reporter:
              Christopher Gervais

              Dates

              • Created:
                Updated:
                Resolved: