By alexpott on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
11.5.x
Introduced in version:
11.5.0
Issue links:
Description:
The following functions have been deprecated:
user_role_grant_permissions()
user_role_revoke_permissions()
user_role_change_permissions()
RoleInterface has three new methods to replace the functions.
grantPermissionschangePermissionsrevokePermissions
It is important to use the loadOverrideFree method when interacting with permissions.
Before:
user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments',
'post comments',
'skip comment approval',
]);
After:
Role::loadOverrideFree(RoleInterface::ANONYMOUS_ID)->grantPermissions([
'access comments',
'post comments',
'skip comment approval',
])->save()
Before:
user_role_revoke_permissions(RoleInterface::ANONYMOUS_ID, ['skip comment approval']);
After:
Role::loadOverrideFree(RoleInterface::ANONYMOUS_ID)->revokePermissions([
'skip comment approval',
])->save();
Before:
user_role_change_permissions(RoleInterface::ANONYMOUS_ID, [
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
]);
After:
Role::loadOverrideFree(RoleInterface::ANONYMOUS_ID)->changePermissions([
'access comments' => TRUE,
'post comments' => TRUE,
'skip comment approval' => FALSE,
])->save();
Impacts:
Module developers