Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix deprecation warnings for permissions array in 5.71 #599

Merged
merged 1 commit into from
Mar 14, 2024

Conversation

cviebrock
Copy link
Contributor

@cviebrock cviebrock commented Mar 13, 2024

As of CiviCRM 5.71, these warnings appear:

User deprecated function: Permission 'register to volunteer' should be declared with 'label' and 'description' keys. See https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/ Caller: CRM_Core_Permission::assembleBasicPermissions in CRM_Core_Error::deprecatedWarning() (line 1129 of /var/www/html/vendor/civicrm/civicrm-core/CRM/Core/Error.php).

User deprecated function: Permission 'log own hours' should be declared with 'label' and 'description' keys. See https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/ Caller: CRM_Core_Permission::assembleBasicPermissions in CRM_Core_Error::deprecatedWarning() (line 1129 of /var/www/html/vendor/civicrm/civicrm-core/CRM/Core/Error.php).

...

... along with similar warnings about the rest of the permissions.

I've not done any work with Civi extensions, but looking into the URL provided (https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_permission/), I believe the issue is related to how the permissions are configured in CRM/Volunteer/Permission.php:

    return array(
      'register to volunteer' => array(
        $prefix . ts('register to volunteer', array('domain' => 'org.civicrm.volunteer')),
        ts('Access public-facing volunteer opportunity listings and registration forms', array('domain' => 'org.civicrm.volunteer')),
      ),
      'log own hours' => array(
        $prefix . ts('log own hours', array('domain' => 'org.civicrm.volunteer')),
        ts('Access forms to self-report performed volunteer hours', array('domain' => 'org.civicrm.volunteer')),
      ),
      ...

This array should, I think, be converted to:

    return array(
      'register to volunteer' => array(
        'label' => $prefix . ts('register to volunteer', array('domain' => 'org.civicrm.volunteer')),
        'description' => ts('Access public-facing volunteer opportunity listings and registration forms', array('domain' => 'org.civicrm.volunteer')),
      ),
      'log own hours' => array(
        'label' => $prefix . ts('log own hours', array('domain' => 'org.civicrm.volunteer')),
        'description' => ts('Access forms to self-report performed volunteer hours', array('domain' => 'org.civicrm.volunteer')),
      ),
      ...

etc.. i.e. turn the non-associative array into an associative one with label and description keys.

This PR does that. 😄 (It also reduces the constant definition of array('domain' => 'org.civicrm.volunteer') and just does that once, similar to how the $prefix variable is used.)

@cviebrock cviebrock changed the title turn non-associative array into associative as per https://docs.civic… Fix deprecation warnings for permissions array in 5.71 Mar 13, 2024
@ginkgomzd ginkgomzd merged commit e827d80 into civicrm:master Mar 14, 2024
@ginkgomzd
Copy link
Contributor

Thanks Colin!

@cviebrock
Copy link
Contributor Author

Thanks @ginkgomzd ... for planning purposes on our end, is there an ETA for a new version to be tagged?

@ginkgomzd
Copy link
Contributor

No.

For installs I maintain, I do not "plan" when an instance diverges from official releases. I typically create patch files and document them by putting them in a safe place, ideally with reference to an issue or PR so it will be clear when upstream obviates the patch.

@cviebrock cviebrock deleted the permissions-fix-5.71 branch March 14, 2024 15:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants