I found this reported at #2328411-78: Convert all permissions to yml files and permission callbacks, but not a full issue.

Problem: The modules list at admin/modules should be including 3 admin links per module, where available: Help, Configure, and Permissions. With the move to modulename.permissions.yml files, the call to $this->moduleHandler->getImplementations('permission') in ModulesListForm.php returns no modules.

Proposed solution:

  • Fix it
  • Add test coverage for this link. Cover the help links in a follow-up.

Beta phase evaluation

Reference: https://www.drupal.org/core/beta-changes
Issue category Bug because this fixes a regression.
Issue priority Normal because there is a workaround.
Prioritized changes The main goal of this issue is fixing a bug—it is prioritized.

Comments

akalata’s picture

Issue summary: View changes
akalata’s picture

StatusFileSize
new1009 bytes
akalata’s picture

Status: Active » Needs review
akalata’s picture

Issue tags: +Regression
akalata’s picture

Title: Module permission links missing from module list page » [Regression] Module permission links missing from module list page
les lim’s picture

Status: Needs review » Needs work
  1. +++ b/core/modules/system/src/Form/ModulesListForm.php
    @@ -270,7 +270,8 @@ protected function buildRow(array $modules, Extension $module, $distribution) {
    +    $permission_handler = \Drupal::service('user.permissions');
    

    Let's inject the user.permissions service so we can use $this->permissionHandler instead.

  2. +++ b/core/modules/system/src/Form/ModulesListForm.php
    @@ -270,7 +270,8 @@ protected function buildRow(array $modules, Extension $module, $distribution) {
    +    if ($module->status && \Drupal::currentUser()->hasPermission('administer permissions') && $permission_handler->moduleProvidesPermissions($module->getName())) {
    

    We already have $this->currentUser, so no need for \Drupal::currentUser() here. (That has nothing to do with your patch, but it's an easy thing to fix here.)

Also, since testbot didn't catch it, that means we probably need a test.

les lim’s picture

Sure enough, \Drupal\system\Tests\Form\ModulesListFormWebTest checks for a configure link, but not a permissions link.

cilefen’s picture

Status: Needs work » Needs review
Issue tags: +Needs tests
StatusFileSize
new3.24 KB
new3.54 KB
cilefen’s picture

Here is a tests-only patch and a full patch.

The last submitted patch, 9: regression_module-2513626-9-TESTS.patch, failed testing.

les lim’s picture

Status: Needs review » Needs work

For the sake of completeness, we should also test that the "Help" link is shown. Some day we'll want to get rid of hook_help(), too.

cilefen’s picture

Status: Needs work » Needs review

#11 is out-of-scope. Add another issue for that.

cilefen’s picture

Issue summary: View changes
cilefen’s picture

Issue summary: View changes
les lim’s picture

cilefen’s picture

Issue summary: View changes
les lim’s picture

--- /dev/null
+++ b/core/modules/system/tests/modules/system_test/system_test.permissions.yml
@@ -0,0 +1,2 @@
+system test:
+  title: 'Administer system test'

This is strange -- there's a previously existing system_test.permissions.yml file, but it's in the "src" directory. Does that even work? Git tells me it comes from #2464659: Routes that are varied by the 'user.permissions' cache context for anonymous users must also get the anonymous Role's cache tag.

cilefen’s picture

That is strange. Permissions files don't go there.

cilefen’s picture

It may be that *both* files are being read. Can you see if PageCacheTest fails without the other permisisons.yml file present? I think it will.

les lim’s picture

PageCacheTest passes even without any system_test.permissions.yml.

Technically, permissions.yml isn't required for testing; a permission check is just looking for a string, and that string is programmatically applied to the test user directly in the test method:

    user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, ['pet llamas']);

So I'd venture to say that the YAML file in "src" isn't doing anything at all.

cilefen’s picture

So I'd venture to say that the YAML file in "src" isn't doing anything at all.

I don't want to just remove the file in this issue because #2464659: Routes that are varied by the 'user.permissions' cache context for anonymous users must also get the anonymous Role's cache tag intended it to be there, right or wrong. I think this calls for another novice issue and #9 is still open for review.

les lim’s picture

Status: Needs review » Reviewed & tested by the community

#9 is well-formatted, narrowly scoped, and has verified tests. Looks good to me.

les lim’s picture

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Nice catch!

Committed and pushed to 8.0.x. Thanks! Go TC Drupal Go! :D

  • webchick committed f96deaa on 8.0.x
    Issue #2513626 by cilefen, akalata, Les Lim: [Regression] Module...
naveenvalecha’s picture

Issue tags: +Quickfix
StatusFileSize
new481 bytes

Thanks!
Added new line at the end of system_test.permissions.yml

naveenvalecha’s picture

Status: Fixed » Needs review

changing as per #26

cilefen’s picture

Status: Needs review » Closed (fixed)

@naveenvalecha It has already been committed. Open a follow-up issue to fix any missed problems.

cilefen’s picture

Status: Closed (fixed) » Reviewed & tested by the community

Oh a committer knows about it. Ignore #29.

alexpott’s picture

Status: Reviewed & tested by the community » Fixed

@naveenvalecha please open a follow-up issue - doing follow-ups on issue pollutes issue credit history.

alexpott’s picture

Status: Fixed » Needs work

And once the follow-up is created and linked can this issue by set to fixed.

naveenvalecha’s picture

Status: Needs work » Fixed

Thanks! @alexpott! Fine to create the followup. Added followup https://www.drupal.org/node/2521774

Status: Fixed » Closed (fixed)

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