diff --git a/core/includes/entity.api.php b/core/includes/entity.api.php index 1bf3ef0..5295bbb 100644 --- a/core/includes/entity.api.php +++ b/core/includes/entity.api.php @@ -532,8 +532,8 @@ function hook_entity_field_info_alter(&$info, $entity_type) { * if the implementation has no opinion. */ function hook_entity_field_access($operation, $field, $account) { - if ($field->getName() == 'field_of_interest' && $operation == 'edit') { - return user_access('edit field of interest', $account); + if ($field->getName() == 'field_of_interest' && $operation == 'update') { + return user_access('update field of interest', $account); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php index f6f4e69..fdcd244 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/FieldAccessTest.php @@ -15,11 +15,19 @@ class FieldAccessTest extends DrupalUnitTestBase { /** - * Modules to load code from (no schema installation needed). + * Modules to load code from. * * @var array */ - public static $modules = array('field_sql_storage', 'system', 'text'); + public static $modules = array('entity_test', 'field', 'field_sql_storage', 'system', 'text', 'user'); + + /** + * Holds the currently active global user ID that gets replaced during the + * test. + * + * @var int + */ + protected $activeUid; public static function getInfo() { return array( @@ -31,8 +39,21 @@ public static function getInfo() { protected function setUp() { parent::setUp(); - // Install field and user module schema, register entity_test text field. - $this->enableModules(array('field', 'entity_test', 'user')); + // Install field module schema. + $this->installSchema('field', array('field_config', 'field_config_instance')); + // Register entity_test text field. + entity_test_install(); + // Mask the global user as anonymous to avoid any user account loading. + global $user; + $this->activeUid = $user->uid; + $user->uid = 0; + } + + protected function tearDown() { + // Restore the original global user ID. + global $user; + $user->uid = $this->activeUid; + parent::tearDown(); } /**