diff --git a/core/modules/user/src/Entity/Role.php b/core/modules/user/src/Entity/Role.phpindex 68ddd501f5..1e9be69ee6 100644--- a/core/modules/user/src/Entity/Role.php+++ b/core/modules/user/src/Entity/Role.php@@ -207,7 +207,10 @@ public function calculateDependencies() { $valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions)); $invalid_permissions = array_diff($this->permissions, $valid_permissions); if (!empty($invalid_permissions)) {- throw new \RuntimeException('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".');+ \Drupal::logger('role')->error('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".');+ foreach ($invalid_permissions as $invalid_permission) {+ $this->revokePermission($invalid_permission);+ } } foreach ($valid_permissions as $permission) { // Depend on the module that is providing this permissions.