diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index fd099a95b3ba76a897f2d204e4c16986f1d5c165..8110c8309bd791a6c6a0d99e462a55eed726c776 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -83,7 +83,9 @@ function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) { if ($account->hasPermission('access private content')) { $grants['example'] = array(1); } - $grants['example_author'] = array($account->id()); + if ($account->id()) { + $grants['example_author'] = array($account->id()); + } return $grants; } @@ -175,14 +177,16 @@ function hook_node_access_records(\Drupal\node\NodeInterface $node) { // means there are many groups of just 1 user. // Note that an author can always view his or her nodes, even if they // have status unpublished. - $grants[] = array( - 'realm' => 'example_author', - 'gid' => $node->getOwnerId(), - 'grant_view' => 1, - 'grant_update' => 1, - 'grant_delete' => 1, - 'langcode' => 'ca' - ); + if ($node->getOwnerId()) { + $grants[] = array( + 'realm' => 'example_author', + 'gid' => $node->getOwnerId(), + 'grant_view' => 1, + 'grant_update' => 1, + 'grant_delete' => 1, + 'langcode' => 'ca' + ); + } return $grants; }