Problem/Motivation
Unless I'm using the module incorrectly, it does not seem to work on a Drupal 9 site I'm building. I've also tried it on a bare-bones new installation, in order to rule out other factors.
Steps to reproduce
- Perform a standard install of Drupal 9.4 (9.4.8 in my test site)
- Install and enable Pathauto (with dependencies) and URL Alias Permissions
- Create a user with the Content editor user role
- As user 1, edit the Content editor user role:
- revoke the "Administer URL aliases" and "Create and edit URL aliases" permissions
- grant the "Create and edit Basic page content item URL alias" permission
- As a user with the Content editor user role, create a Basic page node. The field widget to edit the URL alias, which should be on the node edit form if the user has permission, does not appear.
Thanks in advance for any help you can offer!
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | Screenshot 2023-07-17 at 3.03.36 PM.png | 335.66 KB | ayush.pandey |
| #11 | Screenshot 2023-07-17 at 3.51.06 PM.png | 1.13 MB | ayush.pandey |
| #4 | 3313956-4.patch | 5.81 KB | fernly |
Issue fork url_alias_permissions-3313956
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 #2
macdev_drupal commentedGood to know. We had some issues with 9.3 already. Will test with 9.4 in a couple of days.
Comment #3
fernly commentedThe cause is line 182 of file /core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
The access per widget is calculated after building the widget form element.
I think the form alter won't do it anymore. Perhaps the core plugin class PathFieldItemList will need to be extended and altered.
Comment #4
fernly commentedAttached a patch that rewrites the module according to comment #3. Instead of altering a form, the core PathFieldItemList class is replaced and the new access rules are implemented there. The patch also plays nice with pathauto (which does a similar alteration).
The patch should fix the problems with Drupal 9.3.x as well.
Tests were not modified.
Comment #5
fernly commentedI would urge to commit this sooner than later as the module is currently fully broken. Marking the issue as major.
Comment #6
it-cruI'm not using the url_alias_permissions module, but for me I found out it could work also with implementation of hook_field_widget_WIDGET_TYPE_form_alter() for path widget type. Maybe this could also be used in url_alias_permissions module to simplify it a little bit more.
Comment #10
jeroentIn Drupal 9.4 the permission create and edit url aliases was added, which broke this module.
I moved all logic to a hook_entity_field_access() hook and this module should work again correctly.
Comment #11
ayush.pandey commentedFor the module URL Alias Permissions with version: 8.x-1.4, and the issue seems to be resolved by the patch https://www.drupal.org/files/issues/2022-11-15/3313956-4.patch .
Before patch
After patch