civicrm/admin/reltype - Fix warning
authorTim Otten <totten@civicrm.org>
Wed, 4 May 2016 22:44:18 +0000 (15:44 -0700)
committerTim Otten <totten@civicrm.org>
Wed, 4 May 2016 22:44:18 +0000 (15:44 -0700)
Scenario:
 1. Create a new relationship-type. It should target "All Contacts" (not "Individual" or "Organization"). (Note: In the schema, "All Contacts" translates to `contact_type_a=NULL`.)
 2. Reload the list of relationship-types
 3. Observe: Warnings

Notes:
 1. The relationship type appears to work correctly if you try to create
    relationship-instances, so this feels like a cosmetic issue on the listing
    screen.
 2. What a silly place for that code live. Keep calm and carry on.

CRM/Core/Page/Basic.php

index e3c0c4cd3bbf66841529ee9113518731cf709fda..886167b9c1c4f6bbb2661c36b20b04529ada46a1 100644 (file)
@@ -243,8 +243,12 @@ abstract class CRM_Core_Page_Basic extends CRM_Core_Page {
           CRM_Core_DAO::storeValues($object, $values[$object->id]);
 
           if (is_a($object, 'CRM_Contact_DAO_RelationshipType')) {
-            $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
-            $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
+            if (isset($values[$object->id]['contact_type_a'])) {
+              $values[$object->id]['contact_type_a_display'] = $contactTypes[$values[$object->id]['contact_type_a']];
+            }
+            if (isset($values[$object->id]['contact_type_b'])) {
+              $values[$object->id]['contact_type_b_display'] = $contactTypes[$values[$object->id]['contact_type_b']];
+            }
           }
 
           // populate action links