Before I work on the tests as per #45, I thought I could simplify the patch a...

Contribution Date
Technology
Contribution Project
Contribution Details

Before I work on the tests as per #45, I thought I could simplify the patch and update the comments for the new permission. Doing that here.

+++ b/core/modules/user/src/UserAccessControlHandler.php @@ -120,6 +120,9 @@ protected function checkFieldAccess($operation, FieldDefinitionInterface $field_ + if ($field_definition->getName() === 'mail' && $account->hasPermission('view user mail field')) { + return AccessResult::allowed()->cachePerPermissions(); + } return AccessResult::allowedIf($is_own_account)->cachePerUser();

There is also a repeated check in this if condition. The outer switch block already checks this. So, this can be removed. Once we remove this, there is only one conditiion which means we can collapse this 4 lines into a ternary operator.

Also, I am not sure why the reroll in #46 was necessary. The patch in #43 applied cleanly for me on 8.8.x.

Contribution Author
Files count
0
Patches count
0