Problem/Motivation

Drupal 9.3.0-alpha1 introduced a "Manage permissions" tab for each bundle that has associated permissions (https://www.drupal.org/project/drupal/issues/2934995). When you are using admin_toolbar for example with a content type, at the moment you only have "Manage fields", "Manage form display", "Manage display" and "Delete" available as menu links in the sub menu of a bundle.

Proposed resolution

For consistency and and usability reasons it might be a good idea to add a menu link "Manage permissions" for bundles with associated permissions as well

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

rkoller created an issue. See original summary.

paulocs’s picture

Assigned: Unassigned » paulocs
paulocs’s picture

Assigned: paulocs » Unassigned
Status: Active » Needs review

rkoller’s picture

Status: Needs review » Needs work

thanks for the merge request! i've applied the diff to version 3.0.3 first and cleared caches. but unfortunately no menu link for manage permissions is showing in the admin menu. changed the admin_toolbar version to 3.0-dev afterwards and reapplied the patch plus cleared the caches on the drupal 9.3.0 alpha1 but same outcome. :( checked content types, media types, taxonomies and storage types (i have the storage module installed which provides custom entities). also checked admin/structure/menu/manage/admin and the manage permissions menu links also aren't showing there.

p.s. shall i test with version 3.0.3 or preferably 3.0-dev from now on for this issue?

paulocs’s picture

Issue summary: View changes
StatusFileSize
new35.66 KB

Strange because i checkout the branch i worked on, clear the cache and its working to me. I created the MR based on the 3.x branch.

Are you sure you are using 9.3.0-alpha1?
It should work after you applied the patch and clear the cache... Did you try to clear your browser cache as well?

PS: sorry for the image quality.

beatrizrodrigues’s picture

StatusFileSize
new71.6 KB

@rkoller I just tested and the menu is showing to me. I was taking some screenshots to attached

beatrizrodrigues’s picture

I tested at a version before drupal 9.3.0-alpha and all worked fine (i'm mean, nothing is broken), and the menu is showing at drupal 9.3.0-alpha. As you can see at the screenshot above.

beatrizrodrigues’s picture

Status: Needs work » Reviewed & tested by the community

Well, as all seems fine to me, i'm moving to RTBC.

paulocs’s picture

Status: Reviewed & tested by the community » Needs review

Sorry for set back to NR @beatrizrodrigues, but as @rkoller opened the issue, lets see he will be able to use the new feature as well.

beatrizrodrigues’s picture

Status: Needs review » Reviewed & tested by the community

Ow, no problem. I didn't think of this. Thank you for this!

Sorry for the crazy changing of status here, folks

beatrizrodrigues’s picture

Status: Reviewed & tested by the community » Needs review
rkoller’s picture

Status: Needs review » Needs work
StatusFileSize
new72.51 KB
new80.94 KB
new87.92 KB

that really really strange. i've used drush cr several times, cleared the cache globally in the developer menu in safari as well alt clicked the reload button. also tried with claro as well as seven as admin theme (always a drush cr afterwards). also restarted my local instance in ddev. really tried to iron out each and every possible detail i could think of. also tried another round of composer update drupal/admin_toolbar -w but no update found. and the submenu links still dont show up as you can see in the three linked images underneath:

content types shown in the admin_toolbar without the manage permissions submenu

the administration menu page showing the content type menu links missing the manage permissions links

status report showing 9.3.0 alpha1 is installed

the only thing left i could think of for the moment that some other module is interfering in some mysterious way. will uninstall all other non core modules stepwise and clear caches each time and see if the menu links are showing up like for you two. :/ if you have any other suggestions i might try i am all ears. oh and i also checked the source that the patch got applied. i can confirm it was.

paulocs’s picture

Are you logged in as an admin user? (I'm asking because my last shot is that your user does not have the permission to access the permission form)

rkoller’s picture

hm i have only the initially created admin user i am logged in with on that install and the active roles for that user are "authenticated user", "content editor" and "Administrator". :/ maybe i try to install a fresh install of alpha1 and install directly admin_toolbar dev version and apply the patch and see if it works then.

rkoller’s picture

created a completely new project (i use an ansible script for that to keep it reproducible and automated - could upload that in here as well). but same result unable to see the submenu link :( the last thing i might think of is the syntax for the patch in the composer.json. in the extra section i've added the following bit ( but i doubt that that is the reason.

"patchLevel": {
    "drupal/core": "-p2"
 },
 "patches": {
     "drupal/admin_toolbar": {
         "Add a menu link Manage permissions for bundles with associated permissions": "https://git.drupalcode.org/project/admin_toolbar/-/merge_requests/15.diff"
     }
},

but aside that i am out of ideas (am not a programmer) :(

paulocs’s picture

did you check if the source code was changed after apply the patch with composer?

rkoller’s picture

StatusFileSize
new29.33 KB

yep i already mentioned in #13 that i checked if the diff changes got actually applied to the codebase. rechecked now again and all changes in admin_toolbar_tools/src/Plugin/Derivative/ExtraLinks.php got applied. :/ i'll add the file that you are able to compare and diff it with your working one (just had to rename the suffix from php to txt since php is not allowed)

paulocs’s picture

Version: 3.0.3 » 3.x-dev

oh i see... I really don't know the problem, sorry.

rkoller’s picture

I'be brought up the issue at the austin drupal dojo last night. @rocketeerbkw helped narrowing down what is causing the issue. he installed the patch on simplytest me and it worked like when you two tested it. then we commented out the following two lines on my failing installation

<code>$url = Url::fromRoute('entity.' . $bundle->getEntityTypeId() . '.permission_form', [$bundle->getEntityTypeId() => $machine_name]);
    if ($url->access($this->currentUser)) {

as well as the associated closing curly bracket. after that step the manage permissions tab showed up instantly as well as the menu links in the administration menu.
one observation and question about that detail. if you go to admin/people/permissions and take a look at the available field ui permissions you have permissions for administer display, administer fields, administer form display for content, custom blocks and taxonomy but none related to administer permissions there? while in the ExtraLinks.php all the snippets building the "manage..." tabs have no permission checks except the snippet you introduced in the merge request. so is the permission check necessary at all there? and on the other hand would the manage permissions tab need an administer permissions permission in the field ui section. perhaps we could ask @benji about that - the driving force behind the introduction of the manage permission tab.
i've then reverted the commented out lines back to the initial state of your patch and then we started comparing what is the difference between @rocketeerbkw simplytestme install and my failing one. at least we had an idea that it might be permission related. @rocketeerbkw also noted that when he installed simplytestme he just installed admin_toolbar and admin_toolbar_tools stepwise. when i setup a site testing i've automated everything with ansible and i drush en admin_toolbar and admin_toolbar_tools as well as admin_toolbar_links_access_filter at once. since i've been sensitised that it might be a permission related cause i've noticed that admin_toolbar_links_access_filter module description states

Provides a workaround for the common problem that users with 'Use the administration pages and help' permission see menu links they don't have access permission for

i've created a new test site manually and composer required admin_toolbar and installed its modules stepwise afterwards. first admin_toolbar and admin_toolbar_tools. there the manage permissions tab was showing up properly. but as soon as admin_toolbar_links_access_filter was installed the tab disappared. if you uninstall it again the tab as well as the menu links in that administration menu are showing up again. i don't know the exact why but at least i found the root causing it. hope that helps? :)

paulocs’s picture

StatusFileSize
new78.21 KB

Yes, I added the verification mentioned in #20 because its created for every bundle a permission form but not all of them has a real per bundle permission. One example is the comment entity bundle. So if you are logged in as an admin user, even if you install admin_toolbar_links_access_filter, a "Manage permissions" link will be created that will redirect you to a permission denied page because of:

    if (!admin_toolbar_links_access_filter_user_has_admin_role($variables['user'])) {
      admin_toolbar_links_access_filter_filter_non_accessible_links($variables['items']);
    }

See the image attached if i remove the verification. Note that the link is displayed for admin users only...

I only don't know how you can not see the 'Manage permissions' link. I was able to see it even with the admin_toolbar_links_access_filter created. Are you testing it in a custom content type? Does the content type have bundle permission?

rkoller’s picture

StatusFileSize
new173.14 KB

that is really strange. i've updated admin_toolbar on my new 9.3.0 beta1 installation to 3.x-dev and applied the diff. on that install i had only admin_toolbar and admin_toolbar_extra_tools installed. started to make screenshots to demonstrate with those two modules installed everything is working as expected. i then installed admin_toolbar_links_access_filter to demonstrate the effect i've described in #20. did a drush cr several times as well as cleared the browser caches once or twice. but somehow it is working now?!

i am able to see the manage permissions menu link for content types, media types, taxonomy types (Added and example screenshot for the article content type). but for comment types you showed the example for i am not able to. same for contact forms. not sure if contact forms are expected to have the manage permissions tab. same goes for the comment types. but there it should be supported since you've added a screenshot for them?

and i am testing the drupal 9.3.0beta1 with admin_toolbar 3.x-dev as admin user. and i havent tried anything non core.

rkoller’s picture

StatusFileSize
new168.2 KB

it is really really strange. installed coffee ( composer require 'drupal/coffee:^1.2 ) after i've posted the comment. wanted to try if i am able to reach the manage permissions tabs as well. on drush en coffee i got:

[warning] Entity view display 'node.article.default': Component 'comment' was disabled because its settings depend on removed dependencies.
[warning] Entity view display 'node.forum.default': Component 'comment_forum' was disabled because its settings depend on removed dependencies.
[success] Successfully enabled: coffee

cleared caches. reloaded and then that (see screenshot coffee_article_content_type.png). if i uninstall coffee, clear caches the behavior is back to like described in #22 (see article_content_type.png in #22). really confusing :/

paulocs’s picture

comment types have no bundle permission. With the MR created, you can not see it. That is why i added the URL access check.

rkoller’s picture

ahhh okay. was uncertain for a second. thanks for the clarification! then the patch works as expected. shall i set the status to rtbc? cuz there is still the behavior by the coffee module. not sure if that is an issue on the admin_toolbars end related to this issue here or if it is more of a coffee module issue. i've just mentioned it in here because i've noticed while testing and the effect is the exact same like i've experienced with this issue?

paulocs’s picture

I tested with the coffee module enabled and I didn't find any problem...
I have admin_toolbar, admin_toolbar_links_access_filter, admin_toolbar_tools and coffee enabled.

rkoller’s picture

Status: Needs work » Reviewed & tested by the community

thats odd and confusing. i haven't changed anything at all to the time i've tested and wrote answer #27 but the sub menus links are showing up now again. that really confusing. and i am really unable to reproduce nor able to figure what was causing it. but i have the same four modules installed and everything is working. thanks a lot for the fix and your patience following along providing suggestion for possible causes. :) set it to rtbc now.

romainj’s picture

Status: Reviewed & tested by the community » Needs work
romainj’s picture

I'm sorry but I think that there is another problem here.
What is working:
- for Drupal Core before 9.3.0-alpha1 version, everything is working fine. We have no links as expected.
- for Drupal Core since 9.3.0-alpha1 version, it's not always displaying the links! In fact if you clear the cache using Drupal UI, it's fine. But clearing the cache using Drush (10.6.2) it does not work: no links at all.
I think the problem is that we are testing access of the current user before adding those links. So with Drush, no Drupal user, no links. When I commented out this test, it's working fine. We have to check access before displaying those links but not when defining them.
Can anyone else confirm the bug?

WagnerMelo’s picture

Assigned: Unassigned » WagnerMelo

Hi, i'll try work on this issue, and confirm the bug that @romainj tell on #29.

WagnerMelo’s picture

Assigned: WagnerMelo » Unassigned

Hello, i tryied work in this issue, first i tryied confirm the bug mentionated in #29 per @romainj, and i discovery that the patch only works on drupal version 9.3.0.alpha-1, only work in this exactly version, i created another two environments with drupal in version 9.4.2 and 9.2.9, and i this two enviroments i couldn't be able to displaying the extra links of manage permission.
I would like to help more but i'm don't have the knowledge enought to fix this issue, i hope that i has helped with this information.

victorml’s picture

Assigned: Unassigned » victorml

I'll try to work on this issue.

victorml’s picture

Assigned: victorml » Unassigned
Status: Needs work » Needs review

The dynamic routes creation for the permissions forms changed with the release of Drupal 9.4, you can check on the following issue:

#3253955: Let modules opt in to the bundle-specific permissions form

We've updated the route so this feature works according to the changes.

The feature will work only from drupal 9.4 and above.

To test the feature, the cache must be cleared using the interface. (explanation on comment #29)

lucassc’s picture

Assigned: Unassigned » lucassc
lucassc’s picture

Hi!

I confirmed what @victorml said in #33:

That issue was originally fixed in 9.3.x, then reverted because it conflicted with existing admin paths for at least one contrib module.

The route subscriber was replaced with a route provider and the feature now is targeting 9.4.x. The permissions_form (plural) was also tweaked in this commit.

I checked out 3247913-add-a-menu branch for drupal 9.4.6-dev and flush all caches by the site. Everything worked well (attaching before/after screenshots).

Leaving status as "Needs Review" for those who had problems before check it again.

lucassc’s picture

Assigned: lucassc » Unassigned
Anonymous’s picture

Hello,

I've been testing the work done on this issue with Drupal 9.5.x-dev Php8.1 and the dev version of this module with the work done by the #32. After enabling the module I can confirm that the "Manage permissions" links appear in the appropriate places as was already confirmed by the #35. Leaving this as it needs review for the same reason as #35.

lucassc’s picture

Status: Needs review » Reviewed & tested by the community

I think it can be marked as RTBC If no one else disagrees.

romainj’s picture

Thanks to all. My comment #29 is still relevant. You must clear the cache using the UI in order to get the new menu links. Doing the cache rebuild using drush command is not working. To me this is a blocking problem. I will work on this.

romainj’s picture

I think that we do not need to check access to the permissions route here. It's automatically done by drupal Core. When we do not check access then everything is working fine: all permissions menu links are visible after cache rebuild (both via UI or Drush) and it respect permission access of the user (Administer roles and permissions).

  • romainj committed c8d8f72 on 3.x authored by paulocs
    Issue #3247913 by romainj, paulocs, victorml, rkoller, beatrizrodrigues...
romainj’s picture

Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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