diff --git a/core/modules/field/lib/Drupal/field/FieldStorageController.php b/core/modules/field/lib/Drupal/field/FieldStorageController.php index cc879b6..8b0f92e 100644 --- a/core/modules/field/lib/Drupal/field/FieldStorageController.php +++ b/core/modules/field/lib/Drupal/field/FieldStorageController.php @@ -128,7 +128,7 @@ public function loadByProperties(array $conditions = array()) { // Extract the actual value against which the condition is checked. switch ($key) { case 'field_name'; - $checked_value = $field->id; + $checked_value = $field->name; break; default: diff --git a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php index 2bc72a9..1e7a739 100644 --- a/core/modules/field/lib/Drupal/field/Tests/CrudTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/CrudTest.php @@ -192,7 +192,7 @@ function testReadFields() { // Check that 'multi column' criteria works. $fields = field_read_fields(array('id' => $id, 'type' => $field_definition['type'])); $this->assertTrue(count($fields) == 1 && isset($fields[$id]), 'The field was properly read.'); - $fields = field_read_fields(array('field_name' => $field_definition['name'], 'type' => 'foo')); + $fields = field_read_fields(array('name' => $field_definition['name'], 'type' => 'foo')); $this->assertTrue(empty($fields), 'No field was found.'); // Create an instance of the field. diff --git a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php index 5175e0f..7b441eb 100644 --- a/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/FieldInfoTest.php @@ -176,6 +176,7 @@ function testInstancePrepare() { function testInstanceDisabledEntityType() { // For this test the field type and the entity type must be exposed by // different modules. + $this->enableModules(array('node', 'comment')); $field_definition = array( 'name' => 'field', 'entity_type' => 'comment', @@ -187,14 +188,7 @@ function testInstanceDisabledEntityType() { 'entity_type' => 'comment', 'bundle' => 'comment_node_article', ); - $instance = entity_create('field_instance', $instance_definition); - try { - $instance->save(); - $this->fail('No exception was thrown'); - } - catch (\InvalidArgumentException $e) { - $this->assertEqual($e->getMessage(), 'The comment entity type does not exist.'); - } + entity_create('field_instance', $instance_definition); // Disable coment module. This clears field_info cache. module_disable(array('comment')); diff --git a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php index 9953ecb..d4d86ac 100644 --- a/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php +++ b/core/modules/field/lib/Drupal/field/Tests/Views/ApiDataTest.php @@ -29,9 +29,9 @@ public static function getInfo() { function setUp() { parent::setUp(); - $field_names = $this->setUpFields(); + $field_names = $this->setUpFields(1); - // The first one will be attached to nodes only. + // Attach the field to nodes only. $instance = array( 'field_name' => $field_names[0], 'entity_type' => 'node', @@ -39,33 +39,10 @@ function setUp() { ); entity_create('field_instance', $instance)->save(); - // The second one will be attached to users only. - $instance = array( - 'field_name' => $field_names[1], - 'entity_type' => 'user', - 'bundle' => 'user', - ); - entity_create('field_instance', $instance)->save(); - - // The third will be attached to both nodes and users. - $instance = array( - 'field_name' => $field_names[2], - 'entity_type' => 'node', - 'bundle' => 'page', - ); - entity_create('field_instance', $instance)->save(); - $instance = array( - 'field_name' => $field_names[2], - 'entity_type' => 'user', - 'bundle' => 'user', - ); - entity_create('field_instance', $instance)->save(); - // Now create some example nodes/users for the view result. for ($i = 0; $i < 5; $i++) { $edit = array( - 'field_name_0' => array((array('value' => $this->randomName()))), - 'field_name_2' => array((array('value' => $this->randomName()))), + $field_names[0] => array((array('value' => $this->randomName()))), ); $nodes[] = $this->drupalCreateNode($edit); } @@ -114,49 +91,6 @@ function testViewsData() { ), ); $this->assertEqual($expected_join, $data[$revision_table]['table']['join']['node_field_revision']); - - // Check the table and the joins of the second field. - // Attached to both node and user. - $field_2 = $this->fields[2]; - $current_table_2 = DatabaseStorageController::_fieldTableName($field_2); - $revision_table_2 = DatabaseStorageController::_fieldRevisionTableName($field_2); - $data[$current_table_2] = $views_data->get($current_table_2); - $data[$revision_table_2] = $views_data->get($revision_table_2); - - $this->assertTrue(isset($data[$current_table_2])); - $this->assertTrue(isset($data[$revision_table_2])); - // The second field should join against both node and users. - $this->assertTrue(isset($data[$current_table_2]['table']['join']['node'])); - $this->assertTrue(isset($data[$revision_table_2]['table']['join']['node_field_revision'])); - $this->assertTrue(isset($data[$current_table_2]['table']['join']['users'])); - - $expected_join = array( - 'left_field' => 'nid', - 'field' => 'entity_id', - 'extra' => array( - array('field' => 'entity_type', 'value' => 'node'), - array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) - ); - $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['node']); - $expected_join = array( - 'left_field' => 'vid', - 'field' => 'revision_id', - 'extra' => array( - array('field' => 'entity_type', 'value' => 'node'), - array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) - ); - $this->assertEqual($expected_join, $data[$revision_table_2]['table']['join']['node_field_revision']); - $expected_join = array( - 'left_field' => 'uid', - 'field' => 'entity_id', - 'extra' => array( - array('field' => 'entity_type', 'value' => 'user'), - array('field' => 'deleted', 'value' => 0, 'numeric' => TRUE), - ) - ); - $this->assertEqual($expected_join, $data[$current_table_2]['table']['join']['users']); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php index 6495cde..8b7e459 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/FieldOverview.php @@ -497,7 +497,7 @@ public function fieldNameExists($value) { // We need to check inactive fields as well, so we can't use // field_info_fields(). - return (bool) field_read_fields(array('field_name' => $field_name), array('include_inactive' => TRUE)); + return (bool) field_read_fields(array('entity_type' => $this->entity_type, 'name' => $field_name), array('include_inactive' => TRUE)); } } diff --git a/core/modules/file/file.module b/core/modules/file/file.module index 27e498e..a7dfc48 100644 --- a/core/modules/file/file.module +++ b/core/modules/file/file.module @@ -1994,11 +1994,11 @@ function file_get_file_references(File $file, $field = NULL, $age = FIELD_LOAD_R // Filter the static cache down to the requested entries. The usual static // cache is very small so this will be very fast. if ($field || $field_type) { - $fields = entity_load_multiple('field_entity', array_keys($return)); - foreach ($return as $field_id => $data) { - $current_field = $fields[$field_id]; + foreach ($return as $field_name => $data) { + foreach (array_keys($data) as $entity_type) { + $current_field = field_info_field($entity_type, $field_name); if (($field_type && $current_field['type'] != $field_type) || ($field && $field['id'] != $current_field['id'])) { - unset($return[$field_id]); + unset($return[$field_name][$entity_type]); } } }