Invalid permissions message should mention Drupal 9.3 update hook

Created on 19 February 2022, almost 3 years ago
Updated 15 November 2023, about 1 year ago

On a site with invalid permissions, the following message displays:

Invalid permissions will trigger runtime exceptions in Drupal 10. Permissions should be defined in a permissions.yml file or a permission callback.

When upgrading to Drupal 9.3, an update hook deletes invalid permissions. To avoid confusion, the message should mention this when it is displayed on versions older than Drupal 9.3. Otherwise, the user may think they should be doing something to fix the issue when in fact it will get fixed. Perhaps add:

This problem may be automatically corrected by the upgrade to Drupal 9.3.

โœจ Feature request
Status

Active

Version

3.0

Component

User interface

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

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

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I think it is an add-on that you would have to install. You can probably find it with a web search.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance zenimagine

    I found this link but I don't speak English, I use a translator. What command should I enter in cli?

    https://drushcommands.com/drush-9x/role/role:perm:remove/

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance zenimagine

    Do you have a solution because this completely blocks the update to Drupal 10 :

    https://www.drupal.org/project/drupal/issues/3335486 ๐Ÿ’ฌ Unable to upgrade Drupal 9 to Drupal 10 Fixed

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    drush role:perm:remove ROLE 'PERMISSION'

    PERMISSION can be a comma-separated list.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    I discussed this with core committers. There are three ways you would fix this:

    1. Run the 9.3 update that clears it out automatically. For those experiencing this after the 9.3 update, it would be good to know if you did not run that update or imported outdated config that was prior to it being fixed?
    2. Create a custom module to define the permissions you still need and resolve it from there.
    3. Remove the permission assignments.

    Since this is a choice the site owner needs to make, and there is nothing in Drupal core apparently other than the 9.3 update that would automatically fix it, I think the best that Upgrade Status could do is to provide an admin screen with checkboxes to remove the permission assignments.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    I was seeing this on a pre-9.3 site. All I was after was a message telling me that this problem will resolve itself by upgrading to 9.3.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States wxman

    I'm getting that same error on my site as well but my problem is the module it's complaining about was removed a while ago. I have no idea how to remove permissions from a module that doesn't exist anymore.

  • ๐Ÿ‡ณ๐Ÿ‡ฑNetherlands megachriz

    Note that the invalid permissions don't have to be permissions provided by Drupal core. They can come from contrib modules as well.

    I discovered that invalid permissions was a thing after I removed a feed type ( Feeds โ†’ module) on a site. (I realise that I could have known this if I had read the Drupal 9.3 release notes more carefully.)
    So as a module maintainer, I found out that when specifying permissions related to a config entity, since Drupal 9.3 I need to make sure the permissions depend on that config entity. For Feeds, this got fixed in #3327572: [D10] Removing a feed type should clean up permissions โ†’ .

    Anyway, the point is that not every contrib module (that provides permissions based on config entities) may have been adapted yet to the Permissions must exist โ†’ change. So even if you had ran the Drupal 9.3 update, you could still run into this problem when you delete certain config entities (provided by contrib modules) afterwards.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States benjifisher Boston area

    If you upgrade to 9.3 (or 9.4 or 9.5) and run the database updates, then the "phantom permissions" are removed, with some very explicit log messages.

    If you did that, then I think the most likely way to run into trouble is if you later imported configuration that contained the "phantom" permissions. In other words, the question in #15.1 is on point.

    I thought that the suggestion in #7 would work, but it does not. Saving a role with "phantom permissions" in D9 (9.3+) will trigger a deprecation message (but you will never see it) without removing the permission. Saving such a role on D10 will throw an exception, but not delete the permission.

    There is a way to fix it in the admin UI, although it is clunky. It will work on D9 or D10. Go to /admin/config/development/configuration/single/export (export a single config item). Choose Configuration type: Role, then select a role that you have to fix, one at a time. Copy the YAML from that page, then head over to /admin/config/development/configuration/single/import (Single import). Choose Configuration type: Role, then paste in the YAML that you copied. Delete the line(s) for the phantom permission(s), submit the form, and confirm. Go on to the next role.

    If you use config management and a text editor, it is much easier to export, edit, import.

    If there is enough demand for it, I could contribute a module that copies the update function from Drupal 9.3 and provides a form to execute it and give some feedback.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada Liam Morland Ontario, CA ๐Ÿ‡จ๐Ÿ‡ฆ

    Adding a UI to fix this could be helpful. That is not what this issue was created for. I was seeing this on a pre-9.3 site. All I was after was a message telling me that this problem will resolve itself by upgrading to 9.3. As has been observed above, this problem could happen in other ways, post-9.3. That should probably be addressed in a separate issue.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States wxman

    #19 has worked perfectly

  • ๐Ÿ‡ณ๐Ÿ‡ฟNew Zealand xurizaemon ลŒtepoti, Aotearoa ๐Ÿ

    Adding a couple of details which weren't on this issue yet. I'm seeing this with Acquia's Cohesion permissions on a D10 upgrade.

    I haven't yet tested any of the above approaches, but thought I'd capture these details from my quick scout for anyone else who landed here.

  • ๐Ÿ‡ญ๐Ÿ‡บHungary Gรกbor Hojtsy Hungary

    The Remove Invalid Permissions (RIP) module seems to be doing a fine job as far as I see. https://git.drupalcode.org/project/rip/-/commit/3cfade5a4f9841b6d7624aed... -- it implements a drush command and asks for each permission / role combination to confirm. Should Upgrade Status suggest that to use? Did that work for people?

  • #23 I think is working for me, after running that and checking /admin/people/permissions for sanity...
    the "upgrade status" is no longer ocmplaining. thanks Galbor.

  • I followed the steps in #22, running the code using drush core-cli, and that works. I also tried using RIP, and that works too.

    Should Upgrade Status suggest that to use? Did that work for people?

    I do think Upgrade Status should suggest a solution.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia drupalite1411

    rip module is asking to remove permission and shows message that it is removed but upgrade status still showing the permissions issue.
    Module not working for me

Production build 0.71.5 2024