Skip to content
Snippets Groups Projects
Commit 35c4989f authored by Zan Vidmar's avatar Zan Vidmar
Browse files

Issue #3396507: Remove unneeded "use text format text_only_html" permission

Starting with Drupal 9.3.0, all permissions in a user
role must be defined in a module.permissions.yml
file or a permissions callback.
Source: https://www.drupal.org/node/3193348

There is no need for social_course to grant
"use text format text_only_html" as it not provides
or depends on "text_only_html" text format.
parent c45f6324
No related branches found
No related tags found
1 merge request!49Issue #3396507: Remove unneeded "use text format text_only_html" permission
......@@ -136,7 +136,6 @@ function _social_course_get_permissions($role) {
'override course_section promote to front page option',
'override course_section revision option',
'override course_section sticky option',
'use text format text_only_html',
'view unpublished groups',
]);
......@@ -602,3 +601,26 @@ function social_course_update_9501(): void {
}
}
}
/**
* Remove unneeded "use text format text_only_html" permission.
*/
function social_course_update_9502(): void {
$entity_type_manager = \Drupal::entityTypeManager();
$all_permissions = array_keys(\Drupal::service('user.permissions')->getPermissions());
/** @var \Drupal\user\RoleInterface[] $roles */
$roles = $entity_type_manager->getStorage('user_role')->loadMultiple();
$permission_to_check = 'use text format text_only_html';
// If permission is not valid (is not on the list of all permissions),
// we need to revoke it from all existing roles.
if (!in_array($permission_to_check, $all_permissions)) {
foreach ($roles as $role) {
if ($role->hasPermission($permission_to_check)) {
$role->revokePermission($permission_to_check);
$role->save();
}
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment