Remove always-true-if
authorEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 12 Jan 2022 05:06:56 +0000 (18:06 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Wed, 12 Jan 2022 05:06:56 +0000 (18:06 +1300)
We just ensured organization is numeric so .. it is

CRM/Contact/BAO/Contact/Utils.php

index 77b94378642f360c8e5b065928e51561b5df942b..27e5446b28d2d21ac93e063186fbd7fe724c9bfb 100644 (file)
@@ -270,40 +270,37 @@ WHERE  id IN ( $idString )
         ])->execute()->first()['id'];
     }
 
-    if (is_numeric($organization)) {
+    // get the relationship type id of "Employee of"
+    $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
+    if (!$relTypeId) {
+      throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Employee of'"));
+    }
 
-      // get the relationship type id of "Employee of"
-      $relTypeId = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_RelationshipType', 'Employee of', 'id', 'name_a_b');
-      if (!$relTypeId) {
-        throw new CRM_Core_Exception(ts("You seem to have deleted the relationship type 'Employee of'"));
-      }
+    // create employee of relationship
+    [$duplicate, $relationshipIds]
+      = self::legacyCreateMultiple($relTypeId, $organization, $contactID);
 
-      // create employee of relationship
-      [$duplicate, $relationshipIds]
-        = self::legacyCreateMultiple($relTypeId, $organization, $contactID);
+    // In case we change employer, clean previous employer related records.
+    if (!$previousEmployerID && !$newContact) {
+      $previousEmployerID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id');
+    }
+    if ($previousEmployerID &&
+      $previousEmployerID != $organization
+    ) {
+      self::clearCurrentEmployer($contactID, $previousEmployerID);
+    }
 
-      // In case we change employer, clean previous employer related records.
-      if (!$previousEmployerID && !$newContact) {
-        $previousEmployerID = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $contactID, 'employer_id');
-      }
-      if ($previousEmployerID &&
-        $previousEmployerID != $organization
-      ) {
-        self::clearCurrentEmployer($contactID, $previousEmployerID);
-      }
+    // set current employer
+    self::setCurrentEmployer([$contactID => $organization]);
 
-      // set current employer
-      self::setCurrentEmployer([$contactID => $organization]);
-
-      $relationshipParams = [
-        'relationship_ids' => $relationshipIds,
-        'is_active' => 1,
-        'contact_check' => [$organization => TRUE],
-        'relationship_type_id' => $relTypeId . '_a_b',
-      ];
-      // Handle related memberships. CRM-3792
-      self::currentEmployerRelatedMembership($contactID, $organization, $relationshipParams, $duplicate, $previousEmployerID);
-    }
+    $relationshipParams = [
+      'relationship_ids' => $relationshipIds,
+      'is_active' => 1,
+      'contact_check' => [$organization => TRUE],
+      'relationship_type_id' => $relTypeId . '_a_b',
+    ];
+    // Handle related memberships. CRM-3792
+    self::currentEmployerRelatedMembership($contactID, $organization, $relationshipParams, $duplicate, $previousEmployerID);
   }
 
   /**