Deleted Field Prevents Creating New Field with the Same Label Name

Created on 12 January 2024, 11 months ago

summary problem motivation

A field was deleted successfully. If creating a new filed with the same label but different machine name, then error occurs:

RuntimeException: Adding non-existent permissions to a role is not allowed. The incorrect permissions are "view my_deleted_field_name". in Drupal\user\Entity\Role->calculateDependencies() (line 207 of /Users/mylaptopname/drupal/core/modules/user/src/Entity/Role.php).

Steps to reproduce

I have tested this problem multiple times. You can reproduce as below:

  1. Create a new field, say "field_explain" with field label as "Explain". It doesn't matter what field type it is;
  2. without entering any data, delete this field "field_explain". So far so good;
  3. Create a new field, say "field_new_explain" with the same field label as "Explain". Make sure the label is the same as the deleted one. We can make the field type the same as the deleted one, too.
  4. Try to assign private permission, then click save.
  5. Now you will see the expected error warning and get the error message in report

Proposed resolution

What I do to correct this is to add the deleted field back in with different label name, and then deleted it again. Now go back to the new field that I wanted to create and assign correction field permission. Now things back to normal.

Although this bug may not be experienced by many, it still a bug to fix.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

User interface

Created by

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

Comments & Activities

  • Issue created by @sdsc
  • 🇮🇳India rajeev.virasat

    Hi @sdsc, I tried steps to reproduce as you mentioned in the issue but I didn't get error. Update the module and try again, I hope it will work fine.

  • Status changed to Postponed: needs info 9 months ago
  • This ticket can be closed, because I haven't upgraded my core to the latest yet and this issue is minor if still existing.

  • Status changed to Closed: cannot reproduce 9 months ago
  • Status changed to Active 10 days ago
  • 🇦🇹Austria ChrisZZ Vienna

    In my understanding this problem happens because the module does not clean up permissions set if deleting a field that has permissions.

    It is not so minor but can be quite disturbing

Production build 0.71.5 2024