Merge pull request #11593 from mfb/db-error-data-too-long-for-column-subject
authorEileen McNaughton <eileen@mcnaughty.com>
Tue, 6 Feb 2018 23:18:17 +0000 (12:18 +1300)
committerGitHub <noreply@github.com>
Tue, 6 Feb 2018 23:18:17 +0000 (12:18 +1300)
Amount and source could exceed max length of subject column

1  2 
CRM/Activity/BAO/Activity.php

index b728e341e528e9101cd8e6d7edaa50bac2ffd2cc,e3c042f05723e48a13c5ad9e285600a241e04eed..28c4f4566621f678f0245a5e7bc9c107a70596d5
@@@ -596,6 -596,13 +596,6 @@@ class CRM_Activity_BAO_Activity extend
  
      CRM_Contact_BAO_GroupContactCache::opportunisticCacheFlush();
  
 -    if (!empty($params['id'])) {
 -      CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
 -    }
 -    else {
 -      CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
 -    }
 -
      // if the subject contains a ‘[case #…]’ string, file that activity on the related case (CRM-5916)
      $matches = array();
      $subjectToMatch = CRM_Utils_Array::value('subject', $params);
          self::logActivityAction($activity, "Case details for {$matches[1]} not found while recording an activity on case.");
        }
      }
 +    if (!empty($params['id'])) {
 +      CRM_Utils_Hook::post('edit', 'Activity', $activity->id, $activity);
 +    }
 +    else {
 +      CRM_Utils_Hook::post('create', 'Activity', $activity->id, $activity);
 +    }
  
      return $result;
    }
@@@ -2197,7 -2198,8 +2197,8 @@@ WHERE      activity.id IN ($activityIds
            $subject .= " - {$entityObj->source}";
          }
  
-         return $subject;
+         // Amount and source could exceed max length of subject column.
+         return CRM_Utils_String::ellipsify($subject, 255);
      }
    }