Remove incorrect permissions
Closed
Remove incorrect permissions
4 unresolved threads
Closed
requested to merge issue/drupal-3358586:3358586-runtimeexception-adding-non-existent into 11.x
4 unresolved threads
Closes #3358586
Merge request reports
Activity
206 206 $valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions)); 207 207 $invalid_permissions = array_diff($this->permissions, $valid_permissions); 208 208 if (!empty($invalid_permissions)) { 209 throw new \RuntimeException('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".'); 209 \Drupal::logger('role')->error('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".'); 210 foreach ($invalid_permissions as $invalid_permission) { 211 $this->revokePermission($invalid_permission); 212 } - Comment on lines +210 to +212
changed this line in version 2 of the diff
206 206 $valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions)); 207 207 $invalid_permissions = array_diff($this->permissions, $valid_permissions); 208 208 if (!empty($invalid_permissions)) { 209 throw new \RuntimeException('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".'); 209 \Drupal::logger('role')->error('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".'); changed this line in version 3 of the diff
211 211 $valid_permissions = array_intersect($this->permissions, array_keys($permission_definitions)); 212 212 $invalid_permissions = array_diff($this->permissions, $valid_permissions); 213 213 if (!empty($invalid_permissions)) { 214 throw new \RuntimeException('Adding non-existent permissions to a role is not allowed. The incorrect permissions are "' . implode('", "', $invalid_permissions) . '".'); 214 \Drupal::logger('user')->error('Adding non-existent permission(s) to a role is not allowed. Invalid permission(s): @permissions. Role: @label (@id).', [ 215 '@permissions' => implode(', ', $invalid_permissions), 216 '@label' => $this->label(), 217 '@id' => $this->id(), 218 ]); 215 219 } 216 220 foreach ($valid_permissions as $permission) { 217 // Depend on the module that is providing this permissions. 18 21 */ 19 22 protected static $modules = ['system', 'user', 'user_permissions_test']; 20 23 24 /** 25 * {@inheritdoc} 26 */ 27 public function register(ContainerBuilder $container): void { 28 parent::register($container); Since https://www.drupal.org/project/drupal/issues/2903456 isn't in yet, using the BufferingLogger to capture and assert the error log message.
added 1 commit
- 63539fd8 - Update message text and remove non-existent permissions.
Please register or sign in to reply