reverted: --- b/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php +++ a/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php @@ -41,10 +41,7 @@ * Implements EntityFieldAccessCheckInterface::accessEditEntityField(). */ public function accessEditEntityField(EntityInterface $entity, $field_name) { + return $entity->access('update') && field_access('edit', $field_name, $entity->entityType(), $entity); - $instance = field_info_instance($entity->entityType(), $field_name, $entity->bundle()); - $field = field_info_field($field_name); - $field_definition = $field->getFieldDefinition($instance); - return $entity->access('update') && field_access('edit', $field_definition, $entity->entityType(), $entity); } /** reverted: --- b/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php +++ a/core/modules/entity_reference/lib/Drupal/entity_reference/EntityReferenceController.php @@ -77,8 +77,7 @@ throw new AccessDeniedHttpException(); } + if ($field['type'] != 'entity_reference' || !field_access('edit', $field, $entity_type)) { - $field_definition = $field->getFieldDefinition($instance); - if ($field['type'] != 'entity_reference' || !field_access('edit', $field_definition, $entity_type)) { throw new AccessDeniedHttpException(); } diff -u b/core/modules/field/field.api.php b/core/modules/field/field.api.php --- b/core/modules/field/field.api.php +++ b/core/modules/field/field.api.php @@ -2139,9 +2139,8 @@ * * @param $op * The operation to be performed. Possible values: 'edit', 'view'. - * @param array $field_definition - * The field definition array for the instance of the field on which the - * operation is to be performed. + * @param $field + * The field on which the operation is to be performed. * @param $entity_type * The type of $entity; for example, 'node' or 'user'. * @param $entity @@ -2152,7 +2151,7 @@ * @return * TRUE if the operation is allowed, and FALSE if the operation is denied. */ -function hook_field_access($op, array $field_definition, $entity_type, $entity, $account) { +function hook_field_access($op, $field, $entity_type, $entity, $account) { if ($field['field_name'] == 'field_of_interest' && $op == 'edit') { return user_access('edit field of interest', $account); } reverted: --- b/core/modules/field/field.module +++ a/core/modules/field/field.module @@ -942,10 +942,9 @@ * The operation to be performed. Possible values: * - edit * - view + * @param array $field + * The full field structure array for the field on which the operation is to + * be performed. See field_info_field(). - * @param array $field_definition - * The field definition array for the instance of the field on which the - * operation is to be performed. - * See \Drupal\field\Plugin\Core\Entity\Field::getFieldDefinition(). * @param $entity_type * The type of $entity; for example, 'node' or 'user'. * @param $entity @@ -956,7 +955,7 @@ * @return * TRUE if the operation is allowed; FALSE if the operation is denied. */ +function field_access($op, $field, $entity_type, $entity = NULL, $account = NULL) { -function field_access($op, array $field_definition, $entity_type, $entity = NULL, $account = NULL) { global $user; if (!isset($account)) { @@ -965,7 +964,7 @@ foreach (module_implements('field_access') as $module) { $function = $module . '_field_access'; + $access = $function($op, $field, $entity_type, $entity, $account); - $access = $function($op, $field_definition, $entity_type, $entity, $account); if ($access === FALSE) { return FALSE; } diff -u b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php --- b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php +++ b/core/modules/field/lib/Drupal/field/Plugin/views/field/Field.php @@ -100,7 +100,7 @@ */ public function access() { $base_table = $this->get_base_table(); - return field_access('view', $this->field_info->getFieldDefinition(), $this->definition['entity_tables'][$base_table]); + return field_access('view', $this->field_info, $this->definition['entity_tables'][$base_table]); } /** reverted: --- b/core/modules/field/tests/modules/field_test/field_test.field.inc +++ a/core/modules/field/tests/modules/field_test/field_test.field.inc @@ -197,14 +197,14 @@ /** * Implements hook_field_access(). */ +function field_test_field_access($op, $field, $entity_type, $entity, $account) { + if ($field['field_name'] == "field_no_{$op}_access") { -function field_test_field_access($op, array $field_definition, $entity_type, $entity, $account) { - if ($field_definition['field_name'] == "field_no_{$op}_access") { return FALSE; } // Only grant view access to test_view_field fields when the user has // 'view test_view_field content' permission. + if ($field['field_name'] == 'test_view_field' && $op == 'view' && !user_access('view test_view_field content')) { - if ($field_definition['field_name'] == 'test_view_field' && $op == 'view' && !user_access('view test_view_field content')) { return FALSE; } reverted: --- b/core/modules/file/file.module +++ a/core/modules/file/file.module @@ -666,7 +666,7 @@ foreach ($entities as $entity) { $field = field_info_field($field_name); // Check if access to this field is not disallowed. + if (!field_access('view', $field, $entity_type, $entity)) { - if (!field_access('view', $field->getFieldDefinition(), $entity_type, $entity)) { $denied = TRUE; continue; }