Permissions for CiviCRM extensions have no labels on Joomla permissions control page
After upgrading CiviCRM from 5.66 to 5.72, the Joomla permissions page does not render any labels for permissions that relate to CiviCRM extensions (including core extensions). This leads to rather a lot of guesswork!!
The issue seems to be in civiperms.php
, specifically JFormFieldCiviperms::getCiviperms()
. In this method, extension permissions are retrieved and loaded into the master array. However, the permission attributes are indexed numerically, but since CiviCRM 5.71 this format has been deprecated in favour of using an associative (i.e. explicitly keyed) array to define label
and description
. Ref: https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/.
/* excerpt from JFormFieldCiviperms::getCiviperms() */
$extPerms = self::$civiConfig->userPermissionClass->getAllModulePermissions(TRUE);
foreach ($extPerms as $key => $perm) {
$translation = self::$civiConfig->userPermissionClass->translateJoomlaPermission($key);
$actions[] = (object) array(
'name' => $translation[0],
'title' => $perm[0], // ***** this doesn't work any more, needs to be $perm['label'] *****
'description' => $perm[1], // ***** this doesn't work any more, needs to be $perm['description'] *****
);
}
This also causes entries in the error_log
like the following:
[Fri Apr 19 16:04:07.758228 2024] [fcgid:warn] [pid 6673] [client 84.70.161.232:64222] mod_fcgid: stderr: PHP Warning: Undefined array key 0 in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/joomla/libraries/joomla/form/fields/civiperms.php on line 308
[Fri Apr 19 16:04:07.758231 2024] [fcgid:warn] [pid 6673] [client 84.70.161.232:64222] mod_fcgid: stderr: PHP Warning: Undefined array key 1 in /home/cses_org_uk/public_html/administrator/components/com_civicrm/civicrm/joomla/libraries/joomla/form/fields/civiperms.php on line 309
For anyone who is interested, the specific breaking change in core was this one: https://github.com/civicrm/civicrm-core/commit/1318e46c6448454b9417786336d13fd9eb592394#diff-52dd62ec7cfcab9db3412890ae8b092bd5d1706e35f2f63a0f17382bc13d7d4f
I think it's an easy fix to update this code. Will raise a PR.