Dblog warning: pass an array for included groups Caller: CRM_ACL_API::groupPermission Array ( [civi.tag] => deprecated )
Overview
When a user logs in, CiviCRM creates two warnings in the dblog:
pass an array for included groups Caller: CRM_ACL_API::groupPermission Array ( [civi.tag] => deprecated )
This appears to be because of an inconsistency in file CRM/ACL/API/php, as follows (starting at line 133):
/**
* Get all the groups the user has access to for the given operation.
*
* @param int $type
* The type of permission needed.
* @param int|null $contactID
* The contactID for whom the check is made.
*
* @param string $tableName
* @param array|null $allGroups
* @param array $includedGroups
*
* @return array
* the ids of the groups for which the user has permissions
*/
public static function group(
$type,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = 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();
}
return CRM_ACL_BAO_ACL::group($type, (int) $contactID, $tableName, $allGroups, $includedGroups);
}
/**
* Check if the user has access to this group for operation $type
*
* @param int $type
* The type of permission needed.
* @param int $groupID
* @param int|null $contactID
* The contactID for whom the check is made.
* @param string $tableName
* @param array|null $allGroups
* @param array|null $includedGroups
*
* @return bool
*/
public static function groupPermission(
$type,
$groupID,
$contactID = NULL,
$tableName = 'civicrm_saved_search',
$allGroups = NULL,
$includedGroups = NULL
) {
if (!isset(Civi::$statics[__CLASS__]) || !isset(Civi::$statics[__CLASS__]['group_permission'])) {
Civi::$statics[__CLASS__]['group_permission'] = [];
}
if (!$contactID) {
$contactID = CRM_Core_Session::getLoggedInContactID();
}
$key = "{$tableName}_{$type}_{$contactID}";
if (!array_key_exists($key, Civi::$statics[__CLASS__]['group_permission'])) {
Civi::$statics[__CLASS__]['group_permission'][$key] = self::group($type, $contactID, $tableName, $allGroups, $includedGroups);
}
return in_array($groupID, Civi::$statics[__CLASS__]['group_permission'][$key]);
}
The error is posted if $includedGroups is not an array in function group()
(first function). But in function groupPermission()
, $includedGroupshas a default value of NULL, so if that value isn't explictly passed in, the NULL is passed to
group()`, which expects an array, and thus the error happens.
Changing the default value in groupPermission()
to
$includedGroups = []
to match group()
eliminates the warning. Don't know if that has any other side effects, though.
Environment information
- Browser: Safari or Chrome on Mac
- CiviCRM: 5.60.0
- PHP: 7.0/7.1/7.2/7.3/..._
- CMS: Backdrop 1.24.0