Skip to content
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

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

volodymyr-sydor
Copy link
Contributor

@volodymyr-sydor volodymyr-sydor commented Jul 3, 2024

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

@volodymyr-sydor volodymyr-sydor added team: enterprise This PR originates from the ECI team status: needs work This pull request needs more work before it's ready for review type: performance Improve Open Social performance prio: high labels Jul 3, 2024
@volodymyr-sydor volodymyr-sydor added this to the 12.3.6 milestone Jul 3, 2024
@volodymyr-sydor volodymyr-sydor self-assigned this Jul 3, 2024
@volodymyr-sydor volodymyr-sydor changed the title Issue #3458767 by SV: Remove node_grants hooks and related patch Issue #3458767: Replace node grants with entity query access Jul 3, 2024
@volodymyr-sydor volodymyr-sydor force-pushed the feature/3458767-replace-node-grants branch 2 times, most recently from 3e99fe6 to e1b9924 Compare July 4, 2024 11:30
@ribel ribel modified the milestones: 12.3.6, 13.0.0-alpha7 Jul 5, 2024
@volodymyr-sydor volodymyr-sydor force-pushed the feature/3458767-replace-node-grants branch 7 times, most recently from 62ea541 to 4e48cbd Compare September 24, 2024 08:10
Copy link
Contributor

@denis-getopensocial denis-getopensocial left a 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.
Copy link
Contributor

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 {
Copy link
Contributor

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 :)

@nechai nechai force-pushed the feature/3458767-replace-node-grants branch from ec9b509 to a882e33 Compare December 20, 2024 10:18
@ribel ribel added needs work: rebase This pull request is too far behind its target branch and requires a rebase needs work: tests This pull request is missing test coverage and removed needs work: rebase This pull request is too far behind its target branch and requires a rebase labels Dec 20, 2024
@open-social-tugboat
Copy link

Tugboat has finished building the preview for this pull request!

Link:

Dashboard:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs work: tests This pull request is missing test coverage prio: high status: needs work This pull request needs more work before it's ready for review team: enterprise This PR originates from the ECI team type: performance Improve Open Social performance
Development

Successfully merging this pull request may close these issues.

8 participants