From 5c99a0c37864d5e70681aff948d1dfa40fd4ce8c Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 12 Jan 2023 13:01:29 +1300 Subject: [PATCH] Standardise Type on includedGroups --- CRM/ACL/API.php | 8 ++++++-- CRM/ACL/BAO/ACL.php | 14 ++++++++------ CRM/Report/Form.php | 2 +- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/CRM/ACL/API.php b/CRM/ACL/API.php index a02fb38a7c..1bafc8b8b6 100644 --- a/CRM/ACL/API.php +++ b/CRM/ACL/API.php @@ -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(); } diff --git a/CRM/ACL/BAO/ACL.php b/CRM/ACL/BAO/ACL.php index 58b388b733..d1166f87ed 100644 --- a/CRM/ACL/BAO/ACL.php +++ b/CRM/ACL/BAO/ACL.php @@ -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; diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index e74c355a0c..e659a50357 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -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)) { -- 2.25.1