Skip to content

Instantly share code, notes, and snippets.

@fabioneves
Created March 23, 2020 13:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabioneves/84dad717100732a87503ee717a38e40b to your computer and use it in GitHub Desktop.
Save fabioneves/84dad717100732a87503ee717a38e40b to your computer and use it in GitHub Desktop.
Drupal 8 - skip permission check on 'view'
diff --git a/modules/gnode/gnode.module b/modules/gnode/gnode.module
index e1daeca..df0d978 100644
--- a/modules/gnode/gnode.module
+++ b/modules/gnode/gnode.module
@@ -146,6 +146,12 @@ function gnode_node_access(NodeInterface $node, $op, AccountInterface $account)
* @see gnode_node_access_records()
*/
function gnode_node_grants(AccountInterface $account, $op) {
+ // Skip group permission check when viewing nodes.
+ // This dramatically improves performance, if you don't want to limit viewing permissions.
+ if ($op === 'view') {
+ return ['gnode_bypass' => [GNODE_MASTER_GRANT_ID]];
+ }
+
// Provide the master grant for users who can bypass group access.
if ($account->hasPermission('bypass group access')) {
return ['gnode_bypass' => [GNODE_MASTER_GRANT_ID]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment