Problem/Motivation

#3059984: Add new “Content Editor” role to Standard Profile added permissions to a role provided by the standard profile for modules that are not get installed. The system has no knowledge of these permissions at this point. If you go to admin/people/permissions none of the permissions are listed because they cannot possibly by returned by \Drupal::service('user.permissions')->getPermissions().

This is an issue because it blocks the commit of #2571235: [regression] Roles should depend on objects that are building the granted permissions - which is a security critical because roles are not cleaned up when a module is uninstalled meaning that if a module is re-installed users might suddenly get unexpected permissions.

Steps to reproduce

$role = \Drupal\user\Entity\Role::load('content_editor');
array_diff($role->getPermissions(), array_keys(\Drupal::service('user.permissions')->getPermissions()));

This results in the following list of permissions:

=> [
     5 => "access media overview",
     6 => "access news feeds",
     7 => "access printer-friendly version",
     10 => "add content to books",
     13 => "create book content",
     14 => "create content translations",
     15 => "create media",
     16 => "create new books",
     21 => "delete book revisions",
     22 => "delete content translations",
     23 => "delete media",
     25 => "delete own book content",
     29 => "edit own book content",
     34 => "update content translations",
     35 => "update media",
     36 => "use editorial transition archive",
     37 => "use editorial transition archived_draft",
     38 => "use editorial transition archived_published",
     39 => "use editorial transition create_new_draft",
     40 => "use editorial transition publish",
     41 => "view all media revisions",
     43 => "view any unpublished content",
     44 => "view latest version",
     46 => "view own unpublished media",
     47 => "view post access counter",
   ]

Proposed resolution

  1. In this issue - remove the permissions that do not exist - this is the quickest proper fix for the problem that allows #2571235: [regression] Roles should depend on objects that are building the granted permissions to not be reverted.
  2. #3221259: Add permissions for optional modules to content editor role as they become enabled - discuss solutions that allow the permissions to be added to the content editor role as modules are enabled.

Remaining tasks

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

Comments

alexpott created an issue. See original summary.

alexpott’s picture

Issue summary: View changes
alexpott’s picture

Status: Active » Needs review
StatusFileSize
new3.42 KB
aaronmchale’s picture

My first thought would be, how many of the permissions in question relate to modules that will be installed in the standard profile in the future (e.g. media, content moderation, etc)?

There were extensive discussions around the content editor role during UX Calls, and if I remember correctly, we did discuss the idea of adding permissions to the role as those modules become included in the standard profile.

I think the easy approach is just to remove the effected permissions, and then create separate issues for the relevant modules that will eventually be installed in the standard profile to update the content editor role as part of the inclusion process.

The thing that we discussed during the UX Calls is that this role (and the Content Manager role) is really just meant to be a sensible starting point, not really a be-all-end-all of that type of role. We noted that we wouldn't want to then later update existing sites because they may have customised this role beyond what our default is meant to represent, and maybe deleted it all together. With that in mind I think using hooks to add the permissions on install of specific modules is probably a bit overkill for what the intention of these roles are supposed to be, and possibly could create more problems for existing sites.

Thanks,
-Aaron

alexpott’s picture

Issue summary: View changes
StatusFileSize
new911 bytes
new2.53 KB

Whoops some cruft got in from another issue.

@AaronMcHale thanks for the comment - I like the idea of getting the modules installed as part of standard - I've filed #3221259: Add permissions for optional modules to content editor role as they become enabled for what to do next.

aaronmchale’s picture

Thanks @alexpott

I'll re-post my previous comment in that issue as well as it's probably quite relevant there.

Thanks,
-Aaron

benjifisher’s picture

Status: Needs review » Needs work

The patch needs a reroll after #3221206: Fix indentation in user.role.content_editor.yml. Sorry, I should have caught the indentation problem when I reviewed #3059984: Add new “Content Editor” role to Standard Profile.

I was aware of the conflict, but I thought that we could fix it as part of whichever issue was fixed last. That turns out to mean #2571235: [regression] Roles should depend on objects that are building the granted permissions. I am happy to review the fix here instead.

If there is support for adding modules such as Content Moderation to the Standard profile, then that will be a good solution. I hope we can manage it before 9.3.0 is released. Another alternative is to add a new profile to Drupal core. I suggested this at one of the usability meetings, and I think the main objection was that it would create a maintenance burden.

alexpott’s picture

Priority: Major » Critical

This should be critical because it currently blocking one. I wished I'd reverted #3059984: Add new “Content Editor” role to Standard Profile instead of attempting to keep it in.

alexpott’s picture

Status: Needs work » Needs review
StatusFileSize
new1.77 KB

Rebased and resolved the conflicts.

benjifisher’s picture

Status: Needs review » Reviewed & tested by the community

I checked the removed permissions. They are from the following modules, none of which are enabled in the Standard profile:

  • aggregator
  • book
  • content_moderation
  • content_translation
  • media
  • statistics

I also tested as follows:

The same permissions were removed.

  • catch committed 4fef3bd on 9.3.x
    Issue #3221258 by alexpott, AaronMcHale, benjifisher: Fix content editor...
catch’s picture

Status: Reviewed & tested by the community » Fixed

Committed 4fef3bd and pushed to 9.3.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.