Generated with the help of an LLM.
I used Claude to help write this summary, the code and the tests. I reviewed and tested everything myself.
Problem/Motivation
Child of #3561626. The content type add route (node.type_add, /admin/structure/types/add) and the role add route (user.role_add,
/admin/people/roles/add) only check a permission, so hook_entity_create_access() and hook_ENTITY_TYPE_create_access() are never called for
them. A module that forbids creating node_type or user_role entities can't block these add forms. Restricting who can create content types was the case
that started #3561626.
The role route was first reported in #3644297, which was combined into this issue.
Proposed resolution
Use _entity_create_access instead of _permission on both routes, like the menu, text format and language add routes already do. The admin permissions
of node_type (administer content types) and user_role (administer permissions) are the same permissions the routes check today,
so nothing changes for sites that don't implement the hook.
Remaining tasks
Review the MR.
| Comment | File | Size | Author |
|---|
Issue fork drupal-3643704
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #3
deruina commentedComment #4
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #5
deruina commentedRebased on main and added #[ShareEnvironment(FALSE)] to the new kernel test, which core requires since #3623409. PHPStan and the test pass locally.
Comment #6
smustgrave commentedFor this one I don't think we need a whole new test file why not NodeAccessTest? This is where AI tests are annoying because they just make a new file and never look to extend an existing file or even an existing test.
Comment #7
deruina commentedThanks @smustgrave, fair point. Moved the test into the existing
NodeAccessTestastestNodeTypeAddRouteAccess()and deleted the new file. It stillfails without the routing change.
Comment #8
smustgrave commentedInsread of opening more tickets should we combine #3644297: Add role route ignores hook_entity_create_access() ?
Comment #9
deruina commentedComment #10
deruina commentedComment #11
deruina commentedThanks @smustgrave, done: the add role route change and its test from #3644297 are now in this MR, and I'll close that issue as a duplicate.
There are three more add routes with the same problem: comment type, date format, and view/form modes. Should I add them here too, instead of opening new issues? (cc @prudloff,
who suggested child issues in #3561626)