FilterPermissions' use of URLs can cause module installations to fail

Created on 24 January 2022, over 2 years ago
Updated 19 September 2024, 9 days ago

Problem/Motivation

I am seeing all sorts of functional test issues in my project after upgrading from 9.2.11 to 9.3. I have a few custom modules that add some view configs and also some role configs. The tests are pretty basic...create a few nodes, then visit a view page and make sure the nodes are all displaying. However, all the tests are now failing, and the html output shows a 'page not found' error when visiting the view page. 9.2.11 these tests all work, 9.3.0 they do not. I noticed each one of these custom modules each provide a custom role that I created. If I remove these role configs from the module /config/install directories, all the tests start to pass. Why would the existence of these role configs cause these unit tests to fail? In my test if I log in as an admin and check the /admin/structure/views page, I can see that my view is there after viewing the html output. So why would a simple $this->drupalGet('view-page-url-here'); show a 404 when a role config is present?

Steps to reproduce

1. Create a basic custom module.
2. Through the UI, create a view page. Make the view do something simple (for instance, display the node title of all published nodes).
3. Export this view and put it in /config/install of the custom module.
4. Create a functional test that adds some page nodes using $this->drupalCreateNode(). Make sure the node titles are all appearing (or even just make sure the view page exists doing something like $this->drupalGet('view-page-url-here') then a $this->assertSession()->statusCodeEquals(200);.
5. Run the test. It should pass.
6. Now, through the UI, add a custom role.
7. Export the role config and put it in /config/install of that custom module.
8. Run the functional test again. The test will fail, and if you inspect the html output, you can see the view page does not exist (shows a 404).
9. Remove the role config from /config/install and run the test again. It will pass.

The role doesn't need to have any permissions set or anything. Just the existence of this role config in /config/install seems to break functional tests that involve going to a view page. I tried adding a test role in /config/install for some of my custom modules that do not supply a view page, and those tests still pass.

Any ideas on what could be happening here?

🐛 Bug report
Status

Needs review

Version

11.0 🔥

Component
Base 

Last updated 3 minutes ago

Created by

Live updates comments and jobs are added and updated live.
  • Needs tests

    The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇺🇸United States dpagini

    Hey Wim - I see this has been up here for 6+ months, but I hadn't noticed it until now, apologies. I'd be happy to help test out a proposed fix, but I see that this is failing for maybe a PHPUnit rule to make sure that \Drupal\Core namespace does not get called from \Drupal\Components...? Given that rule, a fix like this wouldn't be able to go in, would it? If you'd like, I can still try this fix against my project's problem and see if that solves the issue if it helps move this along...?

    My team is currently using a custom version of the work-around Alex suggested, and that has been working for us.

  • Status changed to Needs review 10 days ago
  • 🇮🇳India mrinalini9 New Delhi

    Hi,

    Fixed the test case failure issue in #20, please review it.

    Thanks!

  • Merge request !9538Added changes from patch #24. → (Open) created by mrinalini9
  • Pipeline finished with Failed
    9 days ago
    Total: 527s
    #287025
  • 🇺🇸United States smustgrave

    Was previously tagged for tests which still appear to be needed.

    Issue summary also appears to be incomplete

Production build 0.71.5 2024