Problem/Motivation
For users with limited permissions (i.e. content editors), enabling the "access administration pages" permission makes a lot of menu items appear that they don't have access to, which show a "You do not have any administrative items." message. In Drupal 7 it used to be that these menu items were hidden.
Having all these links that go nowhere is not very good UX:

Proposed resolution
Don't show menu items that go to empty administration pages by hiding items marked as having children, but where none of the children are accessible.
Remaining tasks
Commit
User interface changes
Menu items to empty administration pages will be hidden.
API changes
N/A
Data model changes
N/A
Comments
Comment #2
stefan.r commentedReassigning to Admin Toolbar as this is a feature that used to be in admin_menu
Comment #3
stefan.r commentedComment #4
stefan.r commentedTo test:
- create a user with permission "access administration pages" only
- confirm that before applying the patch, the "configuration" menu has many subitems that, when clicked, display an empty page
- apply patch
- confirm that after applying the patch, the subitems are removed
Comment #5
pwolanin commentedThis doesn't seem like a core bug per-se. For these certain listing pages you need to add a check beyond the permissions check?
Comment #6
stefan.r commentedFor now the workaround in this issue should solve the immediate issue with admin_toolbar, created #2856666: Hide administration menu links that do not have visible child links for the core issue.
Comment #7
rutiolmaJust gave it a try and this patch works, fixing the described issue.
Comment #8
stefan.r commentedComment #9
alan d. commentedProbably a duplicate of the core issue #296693: Restrict access to empty top level administration pages, but if the patch works :)
The core has had no love for years.
Common issue in the discussion #2863330: Modifying the admin menu: site building examples
There is also Administration links access filter module too.
Comment #10
eme commentedWell, as there is already a core patch + a module for fixing it, it would be nice to keep Admin Toolbar clean. A solution would be to integrage Administration links access as a submodule of Admin Toolbar untill this bug in fixed in the core.
I'll ask the maintainer of Administration link access filter and add it at least to the Admin toolbar description page.
Comment #11
agoradesign commentedHi there,
I'm the maintainer of Administration link access filter and I'd fully support this idea of merging this in as sub module - also see my comment at #2866592-2: Merge into Admin Toolbar ?
Please feel free to contact me or even just grab the code and use it :) I'm also frequently online on IRC, most of the time hanging around in #drupal-commerce channel
best regards,
Andreas
Comment #12
alan d. commentedPlease don't wait for core lol
Comment #13
agoradesign commentedlol, the only positive thing is that it finally wasn't treated as release blocker for D8 :D
Comment #14
hoemmawelt commentedPatch #3 applied on 1.19 and it works without errors. (The module also works.)
Comment #15
stefan.r commented@eme I had discussed with core maintainers (pwolanin) and they suggested fixing this in admin toolbar instead. Don't wait for core, because I don't think it will be fixed there.
Comment #16
hoemmawelt commentedAfter updating to 8.3.4 the core module Workflows appears as empty menu item. Is this related to this issue?
Module is disabled.
Comment #17
joekersThe patch works fine for me.
Comment #18
joekersActually it turns out that the "content" menu link gets removed.
Comment #19
duneblHere is an updated version, rerolled for last dev...
@joekers: Could you check if the user have the right to add some content? (Don't forget to clear the cache before testing)
Comment #20
joekersYep the user has access, they can see and go to the content page without the patch. I first thought it might be due to it not having any children elements, but the "People" link still shows..
Comment #21
dunebl@joekers:
You are right... looking at the code, if the user doesn't have the right to access
one of the submenu item of any menu link, the former will be removed (Access:Neutral)
In your use case, the user have only "Access the Content overview page" but he can't add content or anything else that any submenu of the content menu item can provide...
I don't see any easy way to change this... but I think this patch doesn't solve the problem as it is adding another "bug"!
Comment #22
joekersThe user has access to add content, it was access to the comments (which is the only link under Content) that allowed the Content link to show. This was better than showing all the other unaccessible links for me so I've settled on giving them this permission for now.
Comment #23
duneblFYI, I am using another patch: https://www.drupal.org/node/2731369#comment-12140124 which adds all the local tasks in the admin menu...
This is why I have other sub items in the content menu...
I think, this can solve your use case without adding the comment permission... (But this will not solve this "bug")
Comment #24
chr.fritschHere is a new patch, with fixed tests
Comment #25
rootworkWhile I understand this is the (very good) reason for this, do we actually want to say this in the code?
I think the first line says what it does; we might not need further explanation.
Comment #26
fenstratHere's a reroll of #24 as it no longer applied because the
administer site configurationpermission in the test was added in #2887439: Fix test.Also removed the "This fixes a regression..." comment noted by @rootwork in #25 as I also agree it's probably not needed.
Comment #27
jeroen_drenth commentedPath #26 also doesn't apply anymore. Here's a new one. If it passes the tests, can it be commited before this happens again, please?
Comment #29
jeroen_drenth commentedOops, forgot to update the test.
Comment #30
jeroen_drenth commentedComment #31
adriancid@eme as this will be fixed in the future in core, I think that we should merge the @agoradesign project (admin_links_access_filter) as a submodule of Admin Toolbar, so when the problem will be fixed in core we can just delete the submodule, and we don't need to change nothing inside the Admin Toolbar module. I don't know what do you think. In my opinion this can be a great feature for the v1.21.
Comment #32
eme commentedI do agree that it does not belong inside Admin Toolbar. Or maybe a separate module that we can deprecate ?
Comment #33
adriancid@eme we can create a submodule of Admin Toolbar to fix this problem and put inside the code of the admin_links_access_filter module. I think that @agoradesign think the same #2866592: Merge into Admin Toolbar ?
Comment #34
eme commentedOk, all right and let's go :)
Comment #35
adriancid@eme, ok, I will work on this in the next days, for the moment I will open the issue and close this as duplicate :-)
Comment #36
adriancidWell the adventure has just started in #2917704: Add Administration links access filter module as Admin Toolbar submodule
Closing as duplicate.
Once we finish I will add credit in the issue to all the people that help here ;-)
Comment #37
adriancidWell the job in #2917704: Add Administration links access filter module as Admin Toolbar submodule is done!
thanks to @all.
Comment #38
ankit agrawal commentedAdding admin_links_access_filter module (sub-module of admin_toolbar) fixed the issue for me. Thanks
Comment #39
amneh.shawish commentedEnable this module Admin Toolbar Links Access Filter to hide an empty administration page from the menu.