-
Notifications
You must be signed in to change notification settings - Fork 168
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #3458767: Replace node grants with entity query access #3961
base: main
Are you sure you want to change the base?
Conversation
3e99fe6
to
e1b9924
Compare
62ea541
to
4e48cbd
Compare
3b2a0de
to
b52e1bb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me once its tested :)
'gnode:b' => [], | ||
]; | ||
$this->assertEquals($expected_result_groups_none, $altered_grants_groups_none); | ||
// @todo Rewrite test with entity query access check. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't approve without any test coverage :)
* @return string | ||
* The node field join alias. | ||
*/ | ||
public function ensureNodeFieldTableJoin(string $field_name): string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like the overall usage of the term Ensure
here, I don't think it make it very clear/usable but I can't come with another naming so I guess it will be fine :)
ec9b509
to
a882e33
Compare
Tugboat has finished building the preview for this pull request! Link: Dashboard: |
Problem
We have the
entity_access_by_field
module which uses node grants to limit the visibility of entities that users can see in different places on the platform but we want to get rid of node grants and replace it with entity query access.Our local tests show that
hook_node_grants()
is slower than query builders on node entity queries.This PR contains the basic (core) tools that allow the use of query builders rather than node grants.
We implement query alter for node entities. It contains the query condition group (with
OR
operator) (see there).The idea is to allow other modules (distro or external) to change only this one query conditions group. For this, developer should implement event subscriber with SocialNodeQueryAccessAlterInterface interface. You can find examples of this event subscriber implementations:
One important thing - if we want to use query builders then we should get rid
hook_node_grants()
.If we have at least one hook implementation the query will be broken and no results returned. For this reason we added social_node_requirements() to notify developers to avoid using this hook with Social.
Solution
Replace node grants with entity query access to improve performance and ensure access is centrally controllable
PRs:
Issue tracker
Theme issue tracker
N/A
How to test
Screenshots
N/A
Release notes
N/A
Change Record
N/A
Translations
N/A