From 896855791e9a6d377e0184666383f0e84009607e Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 16 Aug 2018 15:29:33 -0700 Subject: [PATCH] Permission.php - Disinherit CRM_*_Permission. Fix warning. On a local demo site with CiviVolunteer, anytime I clear the cache (`/civicrm/clearcache`), it shows this warning: > Error message Strict warning: Declaration of > CRM_Volunteer_Permission::check() should be compatible with > CRM_Core_Permission::check($permissions, $contactId = NULL) in > CRM_Core_ClassLoader::loadClass() (line 218 of > /Users/totten/bknix/build/dmaster/sites/all/modules/civicrm/CRM/Core/ClassLoader.php). This is because `CRM_Volunteer_Permission` extends `CRM_Core_Permission` and overrides `check()`, but the signature for upstream `check()` has changed to allow another argument. I don't think the inheritance/override relationship here is functionally required -- as near as I can tell: * Everything in `civicrm-core` which uses `CRM_Core_Permission` calls `CRM_Core_Permission` specifically. They would never substitute with an instance of `CRM_Volunteer_Permission`. * Everything in `civivolunteer` which needs `CRM_Volunteer_Permission` calls `CRM_Volunteer_Permission`. What purpose did the inheritance serve? The idea seems to be this: "within the CiviVolunteer codebase, we want to use an enhanced version of `check()` which wraps around core's `check()`." But you can do wrappers like that without any inheritance. I wanted to see if the inheritance serves another purpose -- e.g. perhaps it calls other inherited methods or properties? I grepped the CiviVolunteer codebase `CRM_Volunteer_Permission`. There were 24 matches, but they only referenced three functions: `check()`, `checkProjectPerms()`, `getVolunteerPermissions()`. All of these functions are specifically defined in `CRM_Volunteer_Permission`. Doesn't seem like anything is meaningfully inherited. I have not done any specific CiviVolunteer UI testing, but this patch does resolve warning. --- CRM/Volunteer/Permission.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CRM/Volunteer/Permission.php b/CRM/Volunteer/Permission.php index fb2427b3..d216dac6 100644 --- a/CRM/Volunteer/Permission.php +++ b/CRM/Volunteer/Permission.php @@ -1,6 +1,6 @@