fix accessing member/contribution count when not enabled
authorJon Goldberg <jon@megaphonetech.com>
Mon, 10 Jan 2022 18:11:57 +0000 (13:11 -0500)
committerTim Otten <totten@civicrm.org>
Tue, 11 Jan 2022 19:05:59 +0000 (11:05 -0800)
CRM/Contact/BAO/Contact.php

index 9cbbb6567ba0725bbef0bf87e214c8971a718324..329ed5e421271ffb2d4c349f807bc60d2ba6bf70 100644 (file)
@@ -2735,10 +2735,16 @@ LEFT JOIN civicrm_email    ON ( civicrm_contact.id = civicrm_email.contact_id )
         return CRM_Core_BAO_Note::getContactNoteCount($contactId);
 
       case 'contribution':
-        return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
+        if (array_key_exists('CiviContribute', CRM_Core_Component::getEnabledComponents())) {
+          return CRM_Contribute_BAO_Contribution::contributionCount($contactId);
+        }
+        return FALSE;
 
       case 'membership':
-        return CRM_Member_BAO_Membership::getContactMembershipCount((int) $contactId, TRUE);
+        if (array_key_exists('CiviMember', CRM_Core_Component::getEnabledComponents())) {
+          return CRM_Member_BAO_Membership::getContactMembershipCount((int) $contactId, TRUE);
+        }
+        return FALSE;
 
       case 'participant':
         return CRM_Event_BAO_Participant::getContactParticipantCount($contactId);