Loading core/modules/node/node.api.php +5 −5 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ * * @param \Drupal\Core\Session\AccountInterface $account * The account object whose grants are requested. * @param string $op * @param string $operation * The node operation to be performed, such as 'view', 'update', or 'delete'. * * @return array Loading @@ -73,7 +73,7 @@ * @see node_access_rebuild() * @ingroup node_access */ function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) { function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $operation) { if ($account->hasPermission('access private content')) { $grants['example'] = [1]; } Loading Loading @@ -253,7 +253,7 @@ function hook_node_access_records_alter(&$grants, \Drupal\node\NodeInterface $no * The $grants array returned by hook_node_grants(). * @param \Drupal\Core\Session\AccountInterface $account * The account requesting access to content. * @param string $op * @param string $operation * The operation being performed, 'view', 'update' or 'delete'. * * @see hook_node_grants() Loading @@ -261,7 +261,7 @@ function hook_node_access_records_alter(&$grants, \Drupal\node\NodeInterface $no * @see hook_node_access_records_alter() * @ingroup node_access */ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface $account, $op) { function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface $account, $operation) { // Our sample module never allows certain roles to edit or delete // content. Since some other node access modules might allow this // permission, we expressly remove it by returning an empty $grants Loading @@ -270,7 +270,7 @@ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface // Get our list of banned roles. $restricted = \Drupal::config('example.settings')->get('restricted_roles'); if ($op != 'view' && !empty($restricted)) { if ($operation != 'view' && !empty($restricted)) { // Now check the roles for this account against the restrictions. foreach ($account->getRoles() as $rid) { if (in_array($rid, $restricted)) { Loading core/modules/node/node.module +6 −6 Original line number Diff line number Diff line Loading @@ -856,11 +856,11 @@ function node_form_system_themes_admin_form_submit($form, FormStateInterface $fo /** * Implements hook_ENTITY_TYPE_access(). */ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { function node_node_access(NodeInterface $node, $operation, AccountInterface $account) { $type = $node->bundle(); // Note create access is handled by hook_ENTITY_TYPE_create_access(). switch ($op) { switch ($operation) { case 'update': $access = AccessResult::allowedIfHasPermission($account, 'edit any ' . $type . ' content'); if (!$access->isAllowed() && $account->hasPermission('edit own ' . $type . ' content')) { Loading Loading @@ -893,7 +893,7 @@ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { * grants array by reference. This hook allows for complex business logic to be * applied when integrating multiple node access modules. * * @param string $op * @param string $operation * The operation that the user is trying to perform. * @param \Drupal\Core\Session\AccountInterface $account * The account object for the user performing the operation. Loading @@ -902,11 +902,11 @@ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { * An associative array in which the keys are realms, and the values are * arrays of grants for those realms. */ function node_access_grants($op, AccountInterface $account) { function node_access_grants($operation, AccountInterface $account) { // Fetch node access grants from other modules. $grants = \Drupal::moduleHandler()->invokeAll('node_grants', [$account, $op]); $grants = \Drupal::moduleHandler()->invokeAll('node_grants', [$account, $operation]); // Allow modules to alter the assigned grants. \Drupal::moduleHandler()->alter('node_grants', $grants, $account, $op); \Drupal::moduleHandler()->alter('node_grants', $grants, $account, $operation); return array_merge(['all' => [0]], $grants); } Loading core/modules/node/src/NodeGrantDatabaseStorage.php +3 −3 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public function checkAll(AccountInterface $account) { /** * {@inheritdoc} */ public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table) { public function alterQuery($query, array $tables, $operation, AccountInterface $account, $base_table) { if (!$langcode = $query->getMetaData('langcode')) { $langcode = FALSE; } Loading @@ -154,7 +154,7 @@ public function alterQuery($query, array $tables, $op, AccountInterface $account // Find all instances of the base table being joined -- could appear // more than once in the query, and could be aliased. Join each one to // the node_access table. $grants = node_access_grants($op, $account); $grants = node_access_grants($operation, $account); // If any grant exists for the specified user, then user has access to the // node for the specified operation. $grant_conditions = $this->buildGrantsQueryCondition($grants); Loading @@ -172,7 +172,7 @@ public function alterQuery($query, array $tables, $op, AccountInterface $account if ($grants_exist) { $subquery->condition($grant_conditions); } $subquery->condition('na.grant_' . $op, 1, '>='); $subquery->condition('na.grant_' . $operation, 1, '>='); // Add langcode-based filtering if this is a multilingual site. if ($is_multilingual) { Loading core/modules/node/src/NodeGrantDatabaseStorageInterface.php +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ public function checkAll(AccountInterface $account); * Query that is being altered. * @param array $tables * A list of tables that need to be part of the alter. * @param string $op * @param string $operation * The operation to be performed on the node. Possible values are: * - "view" * - "update" Loading @@ -45,7 +45,7 @@ public function checkAll(AccountInterface $account); * @return int * Status of the access check. */ public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table); public function alterQuery($query, array $tables, $operation, AccountInterface $account, $base_table); /** * Writes a list of grants to the database, deleting previously saved ones. Loading core/modules/node/tests/modules/node_access_test/node_access_test.module +4 −4 Original line number Diff line number Diff line Loading @@ -49,15 +49,15 @@ * @see node_access_test.permissions.yml * @see node_access_test_node_access_records() */ function node_access_test_node_grants($account, $op) { function node_access_test_node_grants($account, $operation) { $grants = []; $grants['node_access_test_author'] = [$account->id()]; if ($op == 'view' && $account->hasPermission('node test view')) { if ($operation == 'view' && $account->hasPermission('node test view')) { $grants['node_access_test'] = [8888, 8889]; } $no_access_uid = \Drupal::state()->get('node_access_test.no_access_uid', 0); if ($op == 'view' && $account->id() == $no_access_uid) { if ($operation == 'view' && $account->id() == $no_access_uid) { $grants['node_access_all'] = [0]; } return $grants; Loading Loading @@ -146,7 +146,7 @@ function node_access_test_add_field(NodeTypeInterface $type) { /** * Implements hook_ENTITY_TYPE_access(). */ function node_access_test_node_access(NodeInterface $node, $op, AccountInterface $account) { function node_access_test_node_access(NodeInterface $node, $operation, AccountInterface $account) { $secret_catalan = \Drupal::state() ->get('node_access_test_secret_catalan') ?: 0; if ($secret_catalan && $node->language()->getId() == 'ca') { Loading Loading
core/modules/node/node.api.php +5 −5 Original line number Diff line number Diff line Loading @@ -62,7 +62,7 @@ * * @param \Drupal\Core\Session\AccountInterface $account * The account object whose grants are requested. * @param string $op * @param string $operation * The node operation to be performed, such as 'view', 'update', or 'delete'. * * @return array Loading @@ -73,7 +73,7 @@ * @see node_access_rebuild() * @ingroup node_access */ function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $op) { function hook_node_grants(\Drupal\Core\Session\AccountInterface $account, $operation) { if ($account->hasPermission('access private content')) { $grants['example'] = [1]; } Loading Loading @@ -253,7 +253,7 @@ function hook_node_access_records_alter(&$grants, \Drupal\node\NodeInterface $no * The $grants array returned by hook_node_grants(). * @param \Drupal\Core\Session\AccountInterface $account * The account requesting access to content. * @param string $op * @param string $operation * The operation being performed, 'view', 'update' or 'delete'. * * @see hook_node_grants() Loading @@ -261,7 +261,7 @@ function hook_node_access_records_alter(&$grants, \Drupal\node\NodeInterface $no * @see hook_node_access_records_alter() * @ingroup node_access */ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface $account, $op) { function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface $account, $operation) { // Our sample module never allows certain roles to edit or delete // content. Since some other node access modules might allow this // permission, we expressly remove it by returning an empty $grants Loading @@ -270,7 +270,7 @@ function hook_node_grants_alter(&$grants, \Drupal\Core\Session\AccountInterface // Get our list of banned roles. $restricted = \Drupal::config('example.settings')->get('restricted_roles'); if ($op != 'view' && !empty($restricted)) { if ($operation != 'view' && !empty($restricted)) { // Now check the roles for this account against the restrictions. foreach ($account->getRoles() as $rid) { if (in_array($rid, $restricted)) { Loading
core/modules/node/node.module +6 −6 Original line number Diff line number Diff line Loading @@ -856,11 +856,11 @@ function node_form_system_themes_admin_form_submit($form, FormStateInterface $fo /** * Implements hook_ENTITY_TYPE_access(). */ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { function node_node_access(NodeInterface $node, $operation, AccountInterface $account) { $type = $node->bundle(); // Note create access is handled by hook_ENTITY_TYPE_create_access(). switch ($op) { switch ($operation) { case 'update': $access = AccessResult::allowedIfHasPermission($account, 'edit any ' . $type . ' content'); if (!$access->isAllowed() && $account->hasPermission('edit own ' . $type . ' content')) { Loading Loading @@ -893,7 +893,7 @@ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { * grants array by reference. This hook allows for complex business logic to be * applied when integrating multiple node access modules. * * @param string $op * @param string $operation * The operation that the user is trying to perform. * @param \Drupal\Core\Session\AccountInterface $account * The account object for the user performing the operation. Loading @@ -902,11 +902,11 @@ function node_node_access(NodeInterface $node, $op, AccountInterface $account) { * An associative array in which the keys are realms, and the values are * arrays of grants for those realms. */ function node_access_grants($op, AccountInterface $account) { function node_access_grants($operation, AccountInterface $account) { // Fetch node access grants from other modules. $grants = \Drupal::moduleHandler()->invokeAll('node_grants', [$account, $op]); $grants = \Drupal::moduleHandler()->invokeAll('node_grants', [$account, $operation]); // Allow modules to alter the assigned grants. \Drupal::moduleHandler()->alter('node_grants', $grants, $account, $op); \Drupal::moduleHandler()->alter('node_grants', $grants, $account, $operation); return array_merge(['all' => [0]], $grants); } Loading
core/modules/node/src/NodeGrantDatabaseStorage.php +3 −3 Original line number Diff line number Diff line Loading @@ -146,7 +146,7 @@ public function checkAll(AccountInterface $account) { /** * {@inheritdoc} */ public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table) { public function alterQuery($query, array $tables, $operation, AccountInterface $account, $base_table) { if (!$langcode = $query->getMetaData('langcode')) { $langcode = FALSE; } Loading @@ -154,7 +154,7 @@ public function alterQuery($query, array $tables, $op, AccountInterface $account // Find all instances of the base table being joined -- could appear // more than once in the query, and could be aliased. Join each one to // the node_access table. $grants = node_access_grants($op, $account); $grants = node_access_grants($operation, $account); // If any grant exists for the specified user, then user has access to the // node for the specified operation. $grant_conditions = $this->buildGrantsQueryCondition($grants); Loading @@ -172,7 +172,7 @@ public function alterQuery($query, array $tables, $op, AccountInterface $account if ($grants_exist) { $subquery->condition($grant_conditions); } $subquery->condition('na.grant_' . $op, 1, '>='); $subquery->condition('na.grant_' . $operation, 1, '>='); // Add langcode-based filtering if this is a multilingual site. if ($is_multilingual) { Loading
core/modules/node/src/NodeGrantDatabaseStorageInterface.php +2 −2 Original line number Diff line number Diff line Loading @@ -30,7 +30,7 @@ public function checkAll(AccountInterface $account); * Query that is being altered. * @param array $tables * A list of tables that need to be part of the alter. * @param string $op * @param string $operation * The operation to be performed on the node. Possible values are: * - "view" * - "update" Loading @@ -45,7 +45,7 @@ public function checkAll(AccountInterface $account); * @return int * Status of the access check. */ public function alterQuery($query, array $tables, $op, AccountInterface $account, $base_table); public function alterQuery($query, array $tables, $operation, AccountInterface $account, $base_table); /** * Writes a list of grants to the database, deleting previously saved ones. Loading
core/modules/node/tests/modules/node_access_test/node_access_test.module +4 −4 Original line number Diff line number Diff line Loading @@ -49,15 +49,15 @@ * @see node_access_test.permissions.yml * @see node_access_test_node_access_records() */ function node_access_test_node_grants($account, $op) { function node_access_test_node_grants($account, $operation) { $grants = []; $grants['node_access_test_author'] = [$account->id()]; if ($op == 'view' && $account->hasPermission('node test view')) { if ($operation == 'view' && $account->hasPermission('node test view')) { $grants['node_access_test'] = [8888, 8889]; } $no_access_uid = \Drupal::state()->get('node_access_test.no_access_uid', 0); if ($op == 'view' && $account->id() == $no_access_uid) { if ($operation == 'view' && $account->id() == $no_access_uid) { $grants['node_access_all'] = [0]; } return $grants; Loading Loading @@ -146,7 +146,7 @@ function node_access_test_add_field(NodeTypeInterface $type) { /** * Implements hook_ENTITY_TYPE_access(). */ function node_access_test_node_access(NodeInterface $node, $op, AccountInterface $account) { function node_access_test_node_access(NodeInterface $node, $operation, AccountInterface $account) { $secret_catalan = \Drupal::state() ->get('node_access_test_secret_catalan') ?: 0; if ($secret_catalan && $node->language()->getId() == 'ca') { Loading