BAO_Participant - Use default status if not specified for create
authorColeman Watts <coleman@civicrm.org>
Thu, 21 Mar 2019 15:32:02 +0000 (11:32 -0400)
committerColeman Watts <coleman@civicrm.org>
Thu, 21 Mar 2019 15:32:02 +0000 (11:32 -0400)
CRM/Event/BAO/Participant.php

index 889f88b4a42a17ce31ead0e5e8fac8a3310c642a..a58eafc6ebb0324166ad693f042886c04dd4be6a 100644 (file)
@@ -136,8 +136,6 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
 
     $participantBAO->save();
 
-    $session = CRM_Core_Session::singleton();
-
     CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
 
     if (!empty($params['id'])) {
@@ -203,9 +201,12 @@ class CRM_Event_BAO_Participant extends CRM_Event_DAO_Participant {
       return $participant;
     }
 
-    if ((!CRM_Utils_Array::value('id', $params)) ||
+    // Log activity when creating new participant or changing status
+    if (empty($params['id']) ||
       (isset($params['status_id']) && $params['status_id'] != $status)
     ) {
+      // Default status if not specified
+      $participant->status_id = $participant->status_id ?: self::fields()['participant_status_id']['default'];
       CRM_Activity_BAO_Activity::addActivity($participant);
     }