dev/core#2758 - Fix contribution activity campaign propagation ...more
authorEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 17 Aug 2021 23:19:45 +0000 (11:19 +1200)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Tue, 17 Aug 2021 23:19:45 +0000 (11:19 +1200)
Fixes a scenario where the value can be 'null' and then fatals

I hit this creating a new membership record on a stock build

CRM/Contribute/BAO/Contribution.php

index 6e886dca521a8fd21fed85d3f680094af1177330..10d7689d485b0f9ff807d66a3ea71623e3b666b7 100644 (file)
@@ -546,7 +546,7 @@ class CRM_Contribute_BAO_Contribution extends CRM_Contribute_DAO_Contribution {
         'status_id:name' => $isCompleted ? 'Completed' : 'Scheduled',
         'skipRecentView' => TRUE,
         'subject' => CRM_Activity_BAO_Activity::getActivitySubject($contribution),
-        'campaign_id' => $contribution->campaign_id,
+        'campaign_id' => !is_numeric($contribution->campaign_id) ? NULL : $contribution->campaign_id,
         'id' => $existingActivity['id'] ?? NULL,
       ];
       if (!$activityParams['id']) {