Skip to content
Snippets Groups Projects
Commit 5d1599de authored by Jess's avatar Jess
Browse files

Issue #3143605 by andypost, longwave, daffie: Remove unused and broken...

Issue #3143605 by andypost, longwave, daffie: Remove unused and broken update_replace_permissions(), which always throws an exception
parent 88375258
Branches
Tags
8 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!1012Issue #3226887: Hreflang on non-canonical content pages,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10,!596Issue #3046532: deleting an entity reference field, used in a contextual view, makes the whole site unrecoverable,!496Issue #2463967: Use .user.ini file for PHP settings,!144Issue #2666286: Clean up menu_ui to conform to Drupal coding standards,!16Draft: Resolve #2081585 "History storage",!13Resolve #2903456
......@@ -723,34 +723,3 @@ function update_retrieve_dependencies() {
return $return;
}
/**
* Replace permissions during update.
*
* This function can replace one permission to several or even delete an old
* one.
*
* @param array $replace
* An associative array. The keys are the old permissions the values are lists
* of new permissions. If the list is an empty array, the old permission is
* removed.
*/
function update_replace_permissions($replace) {
$prefix = 'user.role.';
$cut = strlen($prefix);
$role_names = \Drupal::service('config.storage')->listAll($prefix);
foreach ($role_names as $role_name) {
$rid = substr($role_name, $cut);
$config = \Drupal::config("user.role.$rid");
$permissions = $config->get('permissions') ?: [];
foreach ($replace as $old_permission => $new_permissions) {
if (($index = array_search($old_permission, $permissions)) !== FALSE) {
unset($permissions[$index]);
$permissions = array_unique(array_merge($permissions, $new_permissions));
}
}
$config
->set('permissions', $permissions)
->save();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment