diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index 6d41d13..280f5c5 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -352,7 +352,7 @@ public function access($operation = 'view', AccountInterface $account = NULL) { } return \Drupal::entityManager() ->getAccessController($this->entityType) - ->access($this, $operation, Language::LANGCODE_DEFAULT, $account); + ->access($this, $operation, $account); } /** diff --git a/core/lib/Drupal/Core/Entity/EntityAccessController.php b/core/lib/Drupal/Core/Entity/EntityAccessController.php index 5583aec..4bef2f1 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessController.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessController.php @@ -50,8 +50,9 @@ public function __construct($entity_type) { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { $account = $this->prepareUser($account); + $langcode = $entity->language()->id; if (($access = $this->getCache($entity->uuid(), $operation, $langcode, $account)) !== NULL) { // Cache hit, no work necessary. @@ -68,14 +69,14 @@ public function access(EntityInterface $entity, $operation, $langcode = Language // - No modules say to deny access. // - At least one module says to grant access. $access = array_merge( - $this->moduleHandler->invokeAll('entity_access', array($entity, $operation, $account, $langcode)), - $this->moduleHandler->invokeAll($entity->entityType() . '_access', array($entity, $operation, $account, $langcode)) + $this->moduleHandler->invokeAll('entity_access', array($entity, $operation, $account)), + $this->moduleHandler->invokeAll($entity->entityType() . '_access', array($entity, $operation, $account)) ); if (($return = $this->processAccessHookResults($access)) === NULL) { // No module had an opinion about the access, so let's the access // controller check create access. - $return = (bool) $this->checkAccess($entity, $operation, $langcode, $account); + $return = (bool) $this->checkAccess($entity, $operation, $account); } return $this->setCache($return, $entity->uuid(), $operation, $langcode, $account); } @@ -115,8 +116,6 @@ protected function processAccessHookResults(array $access) { * @param string $operation * The entity operation. Usually one of 'view', 'update', 'create' or * 'delete'. - * @param string $langcode - * The language code for which to check access. * @param \Drupal\Core\Session\AccountInterface $account * The user for which to check access. * @@ -124,7 +123,7 @@ protected function processAccessHookResults(array $access) { * TRUE if access was granted, FALSE if access was denied and NULL if access * could not be determined. */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { return NULL; } diff --git a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php index 749b9a0..e1e6a9c 100644 --- a/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityAccessControllerInterface.php @@ -8,7 +8,6 @@ namespace Drupal\Core\Entity; use Drupal\Core\Extension\ModuleHandlerInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; /** @@ -27,9 +26,6 @@ * @param string $operation * The operation access should be checked for. * Usually one of "view", "update" or "delete". - * @param string $langcode - * (optional) The language code for which to check access. Defaults to - * Language::LANGCODE_DEFAULT. * @param \Drupal\Core\Session\AccountInterface $account * (optional) The user session for which to check access, or NULL to check * access for the current user. Defaults to NULL. @@ -37,7 +33,7 @@ * @return bool * TRUE if access was granted, FALSE otherwise. */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL); + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL); /** * Checks access to create an entity. diff --git a/core/lib/Drupal/Core/Entity/EntityNG.php b/core/lib/Drupal/Core/Entity/EntityNG.php index 49fa3a0..282068a 100644 --- a/core/lib/Drupal/Core/Entity/EntityNG.php +++ b/core/lib/Drupal/Core/Entity/EntityNG.php @@ -352,7 +352,7 @@ public function access($operation = 'view', AccountInterface $account = NULL) { } return \Drupal::entityManager() ->getAccessController($this->entityType) - ->access($this, $operation, $this->activeLangcode, $account); + ->access($this, $operation, $account); } /** diff --git a/core/modules/action/lib/Drupal/action/ActionAccessController.php b/core/modules/action/lib/Drupal/action/ActionAccessController.php index d94edd3..90975ef 100644 --- a/core/modules/action/lib/Drupal/action/ActionAccessController.php +++ b/core/modules/action/lib/Drupal/action/ActionAccessController.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; class ActionAccessController extends EntityAccessController { @@ -17,7 +16,7 @@ class ActionAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { return user_access('administer actions', $account); } diff --git a/core/modules/block/block.api.php b/core/modules/block/block.api.php index aa915a3..a2ab941 100644 --- a/core/modules/block/block.api.php +++ b/core/modules/block/block.api.php @@ -80,8 +80,6 @@ function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\block\BlockP * The operation to be performed, e.g., 'view', 'create', 'delete', 'update'. * @param \Drupal\user\Entity\User $account * The user object to perform the access check operation on. - * @param string $langcode - * The language code to perform the access check operation on. * * @return bool|NULL * FALSE denies access. TRUE allows access unless another module returns @@ -91,7 +89,7 @@ function hook_block_view_BASE_BLOCK_ID_alter(array &$build, \Drupal\block\BlockP * @see \Drupal\Core\Entity\EntityAccessController::access() * @see \Drupal\block\BlockAccessController::checkAccess() */ -function hook_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\user\Entity\User $account, $langcode) { +function hook_block_access(\Drupal\block\Entity\Block $block, $operation, \Drupal\user\Entity\User $account) { // Example code that would prevent displaying the 'Powered by Drupal' block in // a region different than the footer. if ($operation == 'view' && $block->get('plugin') == 'system_powered_by_block' && $block->get('region') != 'footer') { diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php index 9990a2e..01e148f 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockAccessController.php @@ -19,7 +19,7 @@ class CustomBlockAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return TRUE; } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeAccessController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeAccessController.php index 95b74ac..9a6a3e0 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeAccessController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeAccessController.php @@ -19,7 +19,7 @@ class CustomBlockTypeAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return TRUE; } diff --git a/core/modules/block/lib/Drupal/block/BlockAccessController.php b/core/modules/block/lib/Drupal/block/BlockAccessController.php index 7c61bc6..3a6b2bf 100644 --- a/core/modules/block/lib/Drupal/block/BlockAccessController.php +++ b/core/modules/block/lib/Drupal/block/BlockAccessController.php @@ -53,7 +53,7 @@ public static function createInstance(ContainerInterface $container, $entity_typ /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation != 'view') { return user_access('administer blocks', $account); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php index 800991f..c72f580 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentAccessController.php +++ b/core/modules/comment/lib/Drupal/comment/CommentAccessController.php @@ -21,7 +21,7 @@ class CommentAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'view': return user_access('access comments', $account); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php index f084453..99a67bd 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestAccessController.php @@ -10,7 +10,6 @@ use Drupal\Core\Session\AccountInterface; use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; /** * Defines the access controller for the config_test entity type. @@ -20,7 +19,7 @@ class ConfigTestAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { return TRUE; } diff --git a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php index ba0bab7..5e69d8b 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryAccessController.php @@ -20,7 +20,7 @@ class CategoryAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation == 'delete' || $operation == 'update') { // Do not allow delete 'personal' category used for personal contact form. return user_access('administer contact forms', $account) && $entity->id() !== 'personal'; diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeAccessController.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeAccessController.php index 92e8f42..d74eebc 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayModeAccessController.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayModeAccessController.php @@ -19,7 +19,7 @@ class EntityDisplayModeAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return TRUE; } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php index 0d49189..99a9dfb 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatAccessController.php @@ -19,7 +19,7 @@ class FilterFormatAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { // Handle special cases up front. All users have access to the fallback // format. if ($entity->isFallbackFormat()) { diff --git a/core/modules/image/lib/Drupal/image/ImageStyleAccessController.php b/core/modules/image/lib/Drupal/image/ImageStyleAccessController.php index deb9123..f6f27bf 100644 --- a/core/modules/image/lib/Drupal/image/ImageStyleAccessController.php +++ b/core/modules/image/lib/Drupal/image/ImageStyleAccessController.php @@ -21,7 +21,7 @@ class ImageStyleAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + public function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'create': case 'update': diff --git a/core/modules/language/lib/Drupal/language/LanguageAccessController.php b/core/modules/language/lib/Drupal/language/LanguageAccessController.php index 1609dd0..a8469b3 100644 --- a/core/modules/language/lib/Drupal/language/LanguageAccessController.php +++ b/core/modules/language/lib/Drupal/language/LanguageAccessController.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; class LanguageAccessController extends EntityAccessController { @@ -17,7 +16,7 @@ class LanguageAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { switch ($operation) { case 'update': case 'delete': diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php index a1c2c69..af96f98 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkAccessController.php @@ -21,7 +21,7 @@ class MenuLinkAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { $access = $account->hasPermission('administer menu'); if ($access) { switch ($operation) { diff --git a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php index c44e1f6..52866d4 100644 --- a/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php +++ b/core/modules/node/lib/Drupal/node/Access/NodeRevisionAccessCheck.php @@ -158,7 +158,7 @@ public function checkAccess(NodeInterface $node, $op = 'view', AccountInterface else { // First check the access to the default revision and finally, if the // node passed in is not the default revision then access to that, too. - $this->access[$cid] = $this->nodeAccess->access($this->nodeStorage->load($node->id()), $op, $langcode, $account) && ($node->isDefaultRevision() || $this->nodeAccess->access($node, $op, $langcode, $account)); + $this->access[$cid] = $this->nodeAccess->access($this->nodeStorage->load($node->id()), $op, $langcode, $account) && ($node->isDefaultRevision() || $this->nodeAccess->access($node, $op, $account)); } } diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php index 9071cac..9a03182 100644 --- a/core/modules/node/lib/Drupal/node/Entity/Node.php +++ b/core/modules/node/lib/Drupal/node/Entity/Node.php @@ -156,33 +156,12 @@ public function access($operation = 'view', AccountInterface $account = NULL) { return \Drupal::entityManager() ->getAccessController($this->entityType) - ->access($this, $operation, $this->prepareLangcode(), $account); + ->access($this, $operation, $account); } /** * {@inheritdoc} */ - public function prepareLangcode() { - $langcode = $this->language()->id; - // If the Language module is enabled, try to use the language from content - // negotiation. - if (\Drupal::moduleHandler()->moduleExists('language')) { - // Load languages the node exists in. - $node_translations = $this->getTranslationLanguages(); - // Load the language from content negotiation. - $content_negotiation_langcode = \Drupal::languageManager()->getLanguage(Language::TYPE_CONTENT)->id; - // If there is a translation available, use it. - if (isset($node_translations[$content_negotiation_langcode])) { - $langcode = $content_negotiation_langcode; - } - } - return $langcode; - } - - - /** - * {@inheritdoc} - */ public function getTitle() { return $this->get('title')->value; } diff --git a/core/modules/node/lib/Drupal/node/NodeAccessController.php b/core/modules/node/lib/Drupal/node/NodeAccessController.php index 9b5a403..b064c15 100644 --- a/core/modules/node/lib/Drupal/node/NodeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeAccessController.php @@ -57,14 +57,14 @@ public static function createInstance(ContainerInterface $container, $entity_typ /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { if (user_access('bypass node access', $account)) { return TRUE; } if (!user_access('access content', $account)) { return FALSE; } - return parent::access($entity, $operation, $langcode, $account); + return parent::access($entity, $operation, $account); } /** @@ -86,10 +86,10 @@ public function createAccess($entity_bundle = NULL, AccountInterface $account = /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $node, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $node, $operation, AccountInterface $account) { // Fetch information from the node object if possible. - $status = $node->getTranslation($langcode)->isPublished(); - $uid = $node->getTranslation($langcode)->getAuthorId(); + $status = $node->isPublished(); + $uid = $node->getAuthorId(); // Check if authors can view their own unpublished nodes. if ($operation === 'view' && !$status && user_access('view own unpublished content', $account)) { @@ -101,7 +101,7 @@ protected function checkAccess(EntityInterface $node, $operation, $langcode, Acc // If no module specified either allow or deny, we fall back to the // node_access table. - if (($grants = $this->grantStorage->access($node, $operation, $langcode, $account)) !== NULL) { + if (($grants = $this->grantStorage->access($node, $operation, $account)) !== NULL) { return $grants; } diff --git a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php index fba9847..66ee75e 100644 --- a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php +++ b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorage.php @@ -53,7 +53,7 @@ public function __construct(Connection $database, ModuleHandlerInterface $module /** * {@inheritdoc} */ - public function access(EntityInterface $node, $operation, $langcode, AccountInterface $account) { + public function access(EntityInterface $node, $operation, AccountInterface $account) { // If no module implements the hook or the node does not have an id there is // no point in querying the database for access grants. if (!$this->moduleHandler->getImplementations('node_grants') || !$node->id()) { @@ -68,7 +68,7 @@ public function access(EntityInterface $node, $operation, $langcode, AccountInte // Check for grants for this node and the correct langcode. $nids = $query->andConditionGroup() ->condition('nid', $node->id()) - ->condition('langcode', $langcode); + ->condition('langcode', $node->language()->id); // If the node is published, also take the default grant into account. The // default is saved with a node ID of 0. $status = $node->isPublished(); diff --git a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorageInterface.php b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorageInterface.php index 2457b8f..3453a26 100644 --- a/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorageInterface.php +++ b/core/modules/node/lib/Drupal/node/NodeGrantDatabaseStorageInterface.php @@ -101,8 +101,6 @@ public function writeDefault(); * @param string $operation * The entity operation. Usually one of 'view', 'edit', 'create' or * 'delete'. - * @param string $langcode - * The language code for which to check access. * @param \Drupal\Core\Session\AccountInterface $account * The user for which to check access. * @@ -111,7 +109,7 @@ public function writeDefault(); * module implements hook_node_grants(), the node does not (yet) have an id * or none of the implementing modules explicitly granted or denied access. */ - public function access(EntityInterface $node, $operation, $langcode, AccountInterface $account); + public function access(EntityInterface $node, $operation, AccountInterface $account); /** * Counts available node grants. diff --git a/core/modules/node/lib/Drupal/node/NodeInterface.php b/core/modules/node/lib/Drupal/node/NodeInterface.php index 34f7274..12d334b 100644 --- a/core/modules/node/lib/Drupal/node/NodeInterface.php +++ b/core/modules/node/lib/Drupal/node/NodeInterface.php @@ -187,12 +187,4 @@ public function getRevisionAuthor(); */ public function setRevisionAuthorId($uid); - /** - * Prepares the langcode for a node. - * - * @return string - * The langcode for this node. - */ - public function prepareLangcode(); - } diff --git a/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php b/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php index b7133bd..23816ed 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeAccessController.php @@ -21,7 +21,7 @@ class NodeTypeAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation == 'delete' && $entity->isLocked()) { return FALSE; } diff --git a/core/modules/node/node.api.php b/core/modules/node/node.api.php index 59d27b5..0adcb80 100644 --- a/core/modules/node/node.api.php +++ b/core/modules/node/node.api.php @@ -550,8 +550,6 @@ function hook_node_load($nodes, $types) { * - "view" * @param object $account * The user object to perform the access check operation on. - * @param object $langcode - * The language code to perform the access check operation on. * * @return string * - NODE_ACCESS_ALLOW: if the operation is to be allowed. @@ -560,7 +558,7 @@ function hook_node_load($nodes, $types) { * * @ingroup node_access */ -function hook_node_access(\Drupal\node\NodeInterface $node, $op, $account, $langcode) { +function hook_node_access(\Drupal\node\NodeInterface $node, $op, $account) { $type = is_string($node) ? $node : $node->getType(); $configured_types = node_permissions_get_configured_types(); diff --git a/core/modules/node/node.module b/core/modules/node/node.module index cf31cc4..772194e 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -1629,7 +1629,7 @@ function node_access($op, $node, $account = NULL, $langcode = NULL) { if (empty($langcode)) { $langcode = $node->prepareLangcode(); } - return $access_controller->access($node, $op, $langcode, $account); + return $access_controller->access($node->getTranslation($langcode), $op, $account); } /** diff --git a/core/modules/node/tests/modules/node_access_test/node_access_test.module b/core/modules/node/tests/modules/node_access_test/node_access_test.module index 793c595..f7eebb0 100644 --- a/core/modules/node/tests/modules/node_access_test/node_access_test.module +++ b/core/modules/node/tests/modules/node_access_test/node_access_test.module @@ -153,9 +153,9 @@ function _node_access_test_node_write(EntityInterface $node) { /** * Implements hook_node_access(). */ -function node_access_test_node_access($node, $op, $account, $langcode) { +function node_access_test_node_access($node, $op, $account) { $secret_catalan = \Drupal::state()->get('node_access_test_secret_catalan') ?: 0; - if ($secret_catalan && $langcode == 'ca') { + if ($secret_catalan && $node->language()->id == 'ca') { // Make all Catalan content secret. return NODE_ACCESS_DENY; } diff --git a/core/modules/overlay/overlay.module b/core/modules/overlay/overlay.module index b6194a8..0dc6214 100644 --- a/core/modules/overlay/overlay.module +++ b/core/modules/overlay/overlay.module @@ -300,7 +300,7 @@ function template_preprocess_overlay_disable_message(&$variables) { /** * Implements hook_block_access(). */ -function overlay_block_access(Block $block, $operation, AccountInterface $account, $langcode) { +function overlay_block_access(Block $block, $operation, AccountInterface $account) { // If we are limiting rendering to a subset of page regions, hide all blocks // which appear in regions not on that list. Note that overlay_page_alter() // does a more comprehensive job of preventing unwanted regions from being diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingAccessController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingAccessController.php index 281bcee..1c32fcf 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingAccessController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingAccessController.php @@ -19,7 +19,7 @@ class PictureMappingAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return TRUE; } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php index c60d52a..784ccc6 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetAccessController.php @@ -19,7 +19,7 @@ class ShortcutSetAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'update': if ($account->hasPermission('administer shortcuts')) { diff --git a/core/modules/system/entity.api.php b/core/modules/system/entity.api.php index 8c2c240..b4a2df7 100644 --- a/core/modules/system/entity.api.php +++ b/core/modules/system/entity.api.php @@ -19,8 +19,6 @@ * The operation that is to be performed on $entity. * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. - * @param string $langcode - * The code of the language $entity is accessed in. * * @return bool|null * A boolean to explicitly allow or deny access, or NULL to neither allow nor @@ -28,7 +26,7 @@ * * @see \Drupal\Core\Entity\EntityAccessController */ -function hook_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account, $langcode) { +function hook_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) { return NULL; } @@ -41,8 +39,6 @@ function hook_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operat * The operation that is to be performed on $entity. * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. - * @param string $langcode - * The code of the language $entity is accessed in. * * @return bool|null * A boolean to explicitly allow or deny access, or NULL to neither allow nor @@ -50,7 +46,7 @@ function hook_entity_access(\Drupal\Core\Entity\EntityInterface $entity, $operat * * @see \Drupal\Core\Entity\EntityAccessController */ -function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account, $langcode) { +function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $operation, \Drupal\Core\Session\AccountInterface $account) { return NULL; } @@ -59,8 +55,6 @@ function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $o * * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. - * @param string $langcode - * The code of the language $entity is accessed in. * * @return bool|null * A boolean to explicitly allow or deny access, or NULL to neither allow nor @@ -68,7 +62,7 @@ function hook_ENTITY_TYPE_access(\Drupal\Core\Entity\EntityInterface $entity, $o * * @see \Drupal\Core\Entity\EntityAccessController */ -function hook_entity_create_access(\Drupal\Core\Session\AccountInterface $account, $langcode) { +function hook_entity_create_access(\Drupal\Core\Session\AccountInterface $account) { return NULL; } @@ -77,8 +71,6 @@ function hook_entity_create_access(\Drupal\Core\Session\AccountInterface $accoun * * @param \Drupal\Core\Session\AccountInterface $account * The account trying to access the entity. - * @param string $langcode - * The code of the language $entity is accessed in. * * @return bool|null * A boolean to explicitly allow or deny access, or NULL to neither allow nor @@ -86,7 +78,7 @@ function hook_entity_create_access(\Drupal\Core\Session\AccountInterface $accoun * * @see \Drupal\Core\Entity\EntityAccessController */ -function hook_ENTITY_TYPE_create_access(\Drupal\Core\Session\AccountInterface $account, $langcode) { +function hook_ENTITY_TYPE_create_access(\Drupal\Core\Session\AccountInterface $account) { return NULL; } diff --git a/core/modules/system/lib/Drupal/system/DateFormatAccessController.php b/core/modules/system/lib/Drupal/system/DateFormatAccessController.php index 9608271..0b772ef 100644 --- a/core/modules/system/lib/Drupal/system/DateFormatAccessController.php +++ b/core/modules/system/lib/Drupal/system/DateFormatAccessController.php @@ -19,7 +19,7 @@ class DateFormatAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { // There are no restrictions on viewing a date format. if ($operation == 'view') { return TRUE; diff --git a/core/modules/system/lib/Drupal/system/MenuAccessController.php b/core/modules/system/lib/Drupal/system/MenuAccessController.php index b6e7f7a..a3fa312 100644 --- a/core/modules/system/lib/Drupal/system/MenuAccessController.php +++ b/core/modules/system/lib/Drupal/system/MenuAccessController.php @@ -19,7 +19,7 @@ class MenuAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { return TRUE; } diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php index 034caa3..6a122b4 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestAccessController.php @@ -20,9 +20,9 @@ class EntityTestAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { if ($operation === 'view') { - if ($langcode != Language::LANGCODE_DEFAULT) { + if ($entity->language()->id != Language::LANGCODE_DEFAULT) { return user_access('view test entity translations', $account); } return user_access('view test entity', $account); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermAccessController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermAccessController.php index ca98dbb..68bdf82 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermAccessController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermAccessController.php @@ -21,7 +21,7 @@ class TermAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'view': return $account->hasPermission('access content'); diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyAccessController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyAccessController.php index 56b92ed..5e31373 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyAccessController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyAccessController.php @@ -21,7 +21,7 @@ class VocabularyAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { return $account->hasPermission('administer taxonomy'); } diff --git a/core/modules/user/lib/Drupal/user/RoleAccessController.php b/core/modules/user/lib/Drupal/user/RoleAccessController.php index e98c540..67b51d2 100644 --- a/core/modules/user/lib/Drupal/user/RoleAccessController.php +++ b/core/modules/user/lib/Drupal/user/RoleAccessController.php @@ -19,7 +19,7 @@ class RoleAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'delete': if ($entity->id() == DRUPAL_ANONYMOUS_RID || $entity->id() == DRUPAL_AUTHENTICATED_RID) { diff --git a/core/modules/user/lib/Drupal/user/UserAccessController.php b/core/modules/user/lib/Drupal/user/UserAccessController.php index e6f6ed6..41191a2 100644 --- a/core/modules/user/lib/Drupal/user/UserAccessController.php +++ b/core/modules/user/lib/Drupal/user/UserAccessController.php @@ -19,10 +19,10 @@ class UserAccessController extends EntityAccessController { /** * {@inheritdoc} */ - protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) { + protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) { switch ($operation) { case 'view': - return $this->viewAccess($entity, $langcode, $account); + return $this->viewAccess($entity, $account); break; case 'update': @@ -52,7 +52,7 @@ protected function checkCreateAccess(AccountInterface $account, array $context, * * See EntityAccessControllerInterface::view() for parameters. */ - protected function viewAccess(EntityInterface $entity, $langcode, AccountInterface $account) { + protected function viewAccess(EntityInterface $entity, AccountInterface $account) { // Never allow access to view the anonymous user account. if ($entity->id()) { // Admins can view all, users can view own profiles at all times. diff --git a/core/modules/views/lib/Drupal/views/ViewAccessController.php b/core/modules/views/lib/Drupal/views/ViewAccessController.php index 80ad8a9..4a85402 100644 --- a/core/modules/views/lib/Drupal/views/ViewAccessController.php +++ b/core/modules/views/lib/Drupal/views/ViewAccessController.php @@ -9,7 +9,6 @@ use Drupal\Core\Entity\EntityAccessController; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Language\Language; use Drupal\Core\Session\AccountInterface; /** @@ -20,7 +19,7 @@ class ViewAccessController extends EntityAccessController { /** * {@inheritdoc} */ - public function access(EntityInterface $entity, $operation, $langcode = Language::LANGCODE_DEFAULT, AccountInterface $account = NULL) { + public function access(EntityInterface $entity, $operation, AccountInterface $account = NULL) { return $operation == 'view' || user_access('administer views', $account); }