Closed (fixed)
Project:
Workbench Access
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
15 Nov 2019 at 15:34 UTC
Updated:
25 Dec 2019 at 20:14 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
damontgomery commentedAs far as I can tell, the section information for roles is already cleaned up when a role is deleted. I wrote an automated test for this and tested it manually as well.
I am using:
- Drupal: 8.7.9
- Workbench Access: 1.x-dev
- Palantir.net Drupal Skeleton: https://github.com/palantirnet/drupal-skeleton
- PHPUnit: 6.5.14
- Create two roles, /admin/people/roles/add
- Assign the "Allow all members of this role to be assigned to Workbench Access sections" permission to these roles. (If you assign the permission to authenticated users, it doesn't apply to those roles. :( )
- Create a scheme based on the main navigation, /admin/config/workflow/workbench_access/access_scheme/add, assign it to the Article type that comes with the standard profile
- Assign the two created roles to the top level section
- Confirm the list of roles says "2" and the roles are listed
- Delete one of the roles, /admin/people/roles
- View the list of roles again and confirm it says "1" and the other role is still assigned
- Add another role to the assignment to confirm you can still edit it
The attached patch adds the test for this and updates the interface for role storage. Role IDs in Drupal 8 are strings, not integers.
Let me know if I missed something and there is other behavior we need to test for.
Comment #3
agentrickardThis test is great.
I think the difference is because of how data is stored for the two entity types. Roles are not fielded, so I think all data is stored right on the record.
Comment #4
larowlannit whitespace here
I think the reference to the role still exists in the section storage, but isn't found because \Drupal\workbench_access\RoleSectionStorage::getRoleSections uses
$results = $this->sectionStorage()->loadByProperties(['role_id' => $account->getRoles(), 'access_scheme' => $scheme->id()]);where the call to $account->getRoles() doesn't include the deleted role, becauseuser_user_role_deletedoes the clean up for the user.So I think this might still manifest in things where we don't use the getRoleSections method - possibly in views?
Comment #5
agentrickardSo best practice would be to delete just in case...
Comment #6
agentrickardI updated the test and it shows that we are still storing the data.
Comment #7
agentrickardNew tests pass locally.
Comment #8
larowlanis this change needed?
other than that, looks good
Comment #9
agentrickardI will double check. The test failed if the method stayed private.
Comment #10
agentrickard1) Drupal\Tests\workbench_access\Functional\DeleteRoleTest::testRoleDelete
Error: Call to private method Drupal\workbench_access\RoleSectionStorage::deleteRoleSections() from context ''
That comes from the invocation in:
Which seems like an object context to me, but isn't, clearly. PHP 7.1.22.
Comment #11
agentrickardPR version of the same patch -- https://github.com/agentrickard/workbench_access/pull/136
Comment #12
agentrickardI think we're ok making these methods public since they are not defined in the interface.
Comment #14
agentrickardCommitted.