Standardise Type on includedGroups
authorEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 12 Jan 2023 00:01:29 +0000 (13:01 +1300)
committerEileen McNaughton <emcnaughton@wikimedia.org>
Thu, 12 Jan 2023 01:21:36 +0000 (14:21 +1300)
CRM/ACL/API.php
CRM/ACL/BAO/ACL.php
CRM/Report/Form.php

index a02fb38a7cd68c5796727d06cb16a62bd266bb0d..1bafc8b8b615cc9d3c20ae51c83350926b33ef11 100644 (file)
@@ -140,7 +140,7 @@ class CRM_ACL_API {
    *
    * @param string $tableName
    * @param array|null $allGroups
-   * @param array|null $includedGroups
+   * @param array $includedGroups
    *
    * @return array
    *   the ids of the groups for which the user has permissions
@@ -150,8 +150,12 @@ class CRM_ACL_API {
     $contactID = NULL,
     $tableName = 'civicrm_saved_search',
     $allGroups = NULL,
-    $includedGroups = NULL
+    $includedGroups = []
   ) {
+    if (!is_array($includedGroups)) {
+      CRM_Core_Error::deprecatedWarning('pass an array for included groups');
+      $includedGroups = (array) $includedGroups;
+    }
     if ($contactID == NULL) {
       $contactID = CRM_Core_Session::getLoggedInContactID();
     }
index 58b388b7330c13b08b899aa10b0d1de5e61b0b0c..d1166f87ed674171b131ee683af6345de5f3493e 100644 (file)
@@ -324,7 +324,7 @@ SELECT g.*
    * @param int $contactID
    * @param string $tableName
    * @param array|null $allGroups
-   * @param array|null $includedGroups
+   * @param array $includedGroups
    *
    * @return array
    */
@@ -333,9 +333,13 @@ SELECT g.*
     $contactID = NULL,
     $tableName = 'civicrm_saved_search',
     $allGroups = NULL,
-    $includedGroups = NULL
+    $includedGroups = []
   ) {
-    $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, (array) $includedGroups)));
+    if (!is_array($includedGroups)) {
+      CRM_Core_Error::deprecatedWarning('pass an array for included groups');
+      $includedGroups = (array) $includedGroups;
+    }
+    $userCacheKey = "{$contactID}_{$type}_{$tableName}_" . CRM_Core_Config::domainID() . '_' . md5(implode(',', array_merge((array) $allGroups, $includedGroups)));
     if (empty(Civi::$statics[__CLASS__]['permissioned_groups'])) {
       Civi::$statics[__CLASS__]['permissioned_groups'] = [];
     }
@@ -363,9 +367,7 @@ SELECT g.*
       }
     }
 
-    if (empty($ids) && !empty($includedGroups) &&
-      is_array($includedGroups)
-    ) {
+    if (empty($ids) && !empty($includedGroups)) {
       // This is pretty alarming - we 'sometimes' include all included groups
       // seems problematic per https://lab.civicrm.org/dev/core/-/issues/1879
       $ids = $includedGroups;
index e74c355a0c86e293af8000690954c560b03a52c7..e659a503576429be6da6a7e52b0a394b5cfb0bb1 100644 (file)
@@ -598,7 +598,7 @@ class CRM_Report_Form extends CRM_Core_Form {
     // and addCustomDataToColumns() will allow access to all custom groups.
     $permCustomGroupIds = [];
     if (!CRM_Core_Permission::check('access all custom data')) {
-      $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups, NULL);
+      $permCustomGroupIds = CRM_ACL_API::group(CRM_Core_Permission::VIEW, NULL, 'civicrm_custom_group', $allGroups);
       // do not allow custom data for reports if user doesn't have
       // permission to access custom data.
       if (!empty($this->_customGroupExtends) && empty($permCustomGroupIds)) {