Created
March 23, 2020 13:43
-
-
Save fabioneves/84dad717100732a87503ee717a38e40b to your computer and use it in GitHub Desktop.
Drupal 8 - skip permission check on 'view'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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